index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <div class="terrace pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 10px 80px">
  27. <el-col :span="6" style="width: 303px">
  28. <period-date-picker
  29. :type="1"
  30. :width="'135px'"
  31. :size="searchSize"
  32. :start="parmValue.start"
  33. :end="parmValue.end"
  34. @timeReturned="handleTime"
  35. />
  36. </el-col>
  37. <el-col :span="4" style="width: 160px">
  38. <el-select
  39. v-model="parmValue.status"
  40. filterable
  41. clearable
  42. :size="searchSize"
  43. placeholder="平台状态"
  44. style="width: 100%"
  45. @change="
  46. pageInfo.curr = 1;
  47. parmValue.page = 1;
  48. searchList();
  49. "
  50. >
  51. <el-option
  52. v-for="item in statusList"
  53. :key="'status' + item.code"
  54. :label="item.name"
  55. :value="item.code"
  56. />
  57. </el-select>
  58. </el-col>
  59. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  60. <el-button type="primary" :size="searchSize" @click="searchList">
  61. 刷新
  62. </el-button>
  63. </el-col>
  64. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  65. <el-button type="warning" :size="searchSize" @click="restSearch">
  66. 重置
  67. </el-button>
  68. </el-col>
  69. </el-row>
  70. <el-row>
  71. <el-col :span="4" style="width: 373px">
  72. <el-input
  73. :size="searchSize"
  74. v-model="parmValue.platform_name"
  75. :maxlength="40"
  76. @blur="
  77. pageInfo.curr = 1;
  78. parmValue.page = 1;
  79. searchList();
  80. "
  81. placeholder="平台名称"
  82. ></el-input>
  83. </el-col>
  84. <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
  85. <el-input
  86. :size="searchSize"
  87. v-model="parmValue.creater"
  88. :maxlength="40"
  89. @change="
  90. pageInfo.curr = 1;
  91. parmValue.page = 1;
  92. searchList();
  93. "
  94. placeholder="创建人"
  95. ></el-input>
  96. </el-col>
  97. <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
  98. <el-input
  99. :size="searchSize"
  100. v-model="parmValue.company_name"
  101. :maxlength="40"
  102. @change="
  103. pageInfo.curr = 1;
  104. parmValue.page = 1;
  105. searchList();
  106. "
  107. placeholder="创建人部门"
  108. ></el-input>
  109. </el-col>
  110. <el-col
  111. :span="3"
  112. class="fr"
  113. style="width: 66px; padding: 0 0 0 10px"
  114. v-if="powers.some((item) => item == '003')"
  115. >
  116. <el-button
  117. :size="searchSize"
  118. type="success"
  119. style="float: right"
  120. @click="openModal({}, '003')"
  121. >
  122. 添加
  123. </el-button>
  124. </el-col>
  125. </el-row>
  126. </div></template
  127. >
  128. <template #status="{ scope }">
  129. <el-tag
  130. :size="tablebtnSize"
  131. :type="scope.row.status == '0' ? 'warning' : ''"
  132. v-text="
  133. (statusOptions.find((item) => item.id == scope.row.status) || {}).label ||
  134. '--'
  135. "
  136. ></el-tag>
  137. </template>
  138. <template #platform_type="{ scope }">
  139. <el-tag
  140. :size="tablebtnSize"
  141. v-text="
  142. (options.find((item) => item.value == scope.row.platform_type) || {}).label ||
  143. '--'
  144. "
  145. ></el-tag>
  146. </template>
  147. <template #operation="{ scope }">
  148. <el-tooltip
  149. v-if="powers.some((item) => item == '007')"
  150. effect="dark"
  151. content="详情"
  152. placement="top"
  153. >
  154. <i class="el-icon-view tb-icon" @click="openModal(scope.row, '007')"></i>
  155. </el-tooltip>
  156. <el-tooltip
  157. v-if="powers.some((item) => item == '005')"
  158. effect="dark"
  159. content="修改"
  160. placement="top"
  161. >
  162. <i class="el-icon-edit tb-icon" @click="openModal(scope.row, '005')"></i>
  163. </el-tooltip>
  164. <el-tooltip
  165. v-if="powers.some((item) => item == '004') && scope.row.status === '1'"
  166. effect="dark"
  167. content="禁用"
  168. placement="top"
  169. >
  170. <i
  171. class="el-icon-video-pause tb-icon"
  172. @click="changeStatus(scope.row.id, scope.row.status)"
  173. ></i>
  174. </el-tooltip>
  175. <el-tooltip
  176. v-if="powers.some((item) => item == '004') && scope.row.status === '0'"
  177. effect="dark"
  178. content="启用"
  179. placement="top"
  180. >
  181. <i
  182. class="el-icon-video-play tb-icon"
  183. @click="changeStatus(scope.row.id, scope.row.status)"
  184. ></i>
  185. </el-tooltip>
  186. <el-tooltip
  187. v-if="powers.some((item) => item == '006')"
  188. effect="dark"
  189. content="删除"
  190. placement="top"
  191. >
  192. <i class="el-icon-delete tb-icon" @click="deleteItem(scope.row.id)"></i>
  193. </el-tooltip>
  194. </template>
  195. </ex-table>
  196. <no-auth v-else></no-auth>
  197. <!-- 弹窗 新增/修改 -->
  198. <add-edit
  199. :id="modelId"
  200. :show-model="showModel"
  201. :sitem="sitem"
  202. @refresh="searchList"
  203. @cancel="showModel = false"
  204. />
  205. </div>
  206. </template>
  207. <script>
  208. import addEdit from "./addEdit";
  209. import asyncRequest from "@/apis/service/serviceParam/terrace";
  210. import { statusList } from "@/assets/js/statusList";
  211. import roleLevel from "@/assets/js/roleLevel";
  212. import mixinPage from "@/mixins/elPaginationHandle";
  213. import { mapGetters } from "vuex";
  214. import resToken from "@/mixins/resToken";
  215. export default {
  216. name: "terrace",
  217. mixins: [mixinPage, resToken],
  218. components: {
  219. addEdit,
  220. },
  221. computed: {
  222. //组件SIZE设置
  223. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  224. powers() {
  225. let tran =
  226. this.$store.getters.btnList.find((item) => item.menu_route == "terrace") || {};
  227. if (tran && tran.action && tran.action.length > 0) {
  228. return tran.action;
  229. } else {
  230. return [];
  231. }
  232. },
  233. },
  234. data() {
  235. return {
  236. statusList: statusList,
  237. roleLevel: roleLevel,
  238. loading: true,
  239. showModel: false,
  240. modelId: "000",
  241. sitem: {},
  242. parmValue: {
  243. page: 1, // 页码
  244. size: 15, // 每页显示条数
  245. start: "",
  246. end: "",
  247. company_name: "", //创建人部门
  248. status: "",
  249. creater: "",
  250. platform_name: "",
  251. },
  252. // 状态
  253. statusOptions: [
  254. { id: "0", label: "禁用" },
  255. { id: "1", label: "启用" },
  256. ],
  257. options: [
  258. { value: "0", label: "无对接" },
  259. { value: "1", label: "有赞平台" },
  260. ],
  261. // 表格 - 数据
  262. tableData: [],
  263. // 表格 - 参数
  264. table: {
  265. stripe: true,
  266. border: true,
  267. _defaultHeader_: ["setcol"],
  268. },
  269. // 表格 - 分页
  270. pageInfo: {
  271. size: 15,
  272. curr: 1,
  273. total: 0,
  274. },
  275. // 表格 - 列参数
  276. columns: [
  277. // {
  278. // prop: "id",
  279. // label: "ID",
  280. // },
  281. {
  282. prop: "platform_code",
  283. label: "平台编号",
  284. width: "160px",
  285. },
  286. {
  287. prop: "platform_name",
  288. label: "平台名称",
  289. },
  290. {
  291. prop: "platform_type",
  292. label: "对接平台",
  293. _slot_: "platform_type",
  294. },
  295. {
  296. prop: "status",
  297. label: "状态",
  298. _slot_: "status",
  299. },
  300. {
  301. prop: "creater",
  302. label: "创建人",
  303. },
  304. {
  305. prop: "company_name",
  306. label: "创建人部门",
  307. minWidth: "120px",
  308. },
  309. {
  310. prop: "addtime",
  311. label: "创建时间",
  312. minWidth: "145px",
  313. },
  314. {
  315. prop: "",
  316. label: "操作",
  317. fixed: "right",
  318. _noset_: true,
  319. width: "145px",
  320. _slot_: "operation",
  321. },
  322. ],
  323. };
  324. },
  325. mounted() {
  326. this.searchList();
  327. },
  328. methods: {
  329. restSearch() {
  330. // 表格 - 分页
  331. this.pageInfo = {
  332. size: 15,
  333. curr: 1,
  334. total: 0,
  335. };
  336. this.parmValue = {
  337. page: 1, // 页码
  338. size: 15, // 每页显示条数
  339. start: "",
  340. end: "",
  341. status: "",
  342. company_name: "", //创建人部门
  343. creater: "",
  344. platform_name: "",
  345. };
  346. this.searchList();
  347. },
  348. // 新建/编辑/详情
  349. openModal(row, type) {
  350. const { status } = row;
  351. if (type === "005" && status === "1") {
  352. this.$message.warning("禁用后,才可以修改!");
  353. return;
  354. }
  355. this.sitem = row;
  356. this.modelId = type;
  357. this.showModel = true;
  358. },
  359. // 时间
  360. async handleTime(e) {
  361. this.parmValue.start = e.startTime || "";
  362. this.parmValue.end = e.endTime || "";
  363. if (
  364. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  365. (this.parmValue.start === "" && this.parmValue.end === "")
  366. ) {
  367. this.pageInfo.curr = 1;
  368. this.parmValue.page = 1;
  369. await this.searchList();
  370. }
  371. },
  372. /**
  373. * 启用/禁用
  374. * @param {String} id id
  375. * @param {String} status 0-禁用 1-启用
  376. */
  377. async changeStatus(id, status) {
  378. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  379. confirmButtonText: "确定",
  380. cancelButtonText: "取消",
  381. type: "warning",
  382. })
  383. .then(async () => {
  384. this.loading = true;
  385. const model = {
  386. id: id,
  387. status: status === "1" ? "0" : "1",
  388. };
  389. const res = await asyncRequest.status(model);
  390. if (res && res.code === 0) {
  391. this.loading = false;
  392. this.$notify.success({
  393. title: "状态修改成功!",
  394. message: "",
  395. });
  396. await this.searchList();
  397. } else if (res && res.code >= 100 && res.code <= 104) {
  398. await this.logout();
  399. } else {
  400. this.loading = false;
  401. this.$message.warning(res.message);
  402. }
  403. })
  404. .catch(() => {
  405. console.log("取消");
  406. });
  407. },
  408. async deleteItem(id) {
  409. await this.$confirm("确定要删除?", {
  410. confirmButtonText: "确定",
  411. cancelButtonText: "取消",
  412. type: "warning",
  413. })
  414. .then(async () => {
  415. const model = {
  416. id: id,
  417. };
  418. const res = await asyncRequest.delete(model);
  419. if (res && res.code === 0) {
  420. this.$notify.success({
  421. title: "删除成功",
  422. message: "",
  423. });
  424. this.searchList();
  425. } else if (res && res.code >= 100 && res.code <= 104) {
  426. await this.logout();
  427. } else {
  428. this.$message.warning(res.message);
  429. }
  430. })
  431. .catch(() => {
  432. console.log("取消");
  433. });
  434. },
  435. // 刷新表格
  436. async searchList() {
  437. if (
  438. (this.parmValue.start !== "" && this.parmValue.end === "") ||
  439. (this.parmValue.start == "" && this.parmValue.end != "")
  440. ) {
  441. this.$message.warning("开始时间和结束时间不能为空");
  442. return;
  443. }
  444. this.loading = true;
  445. const res = await asyncRequest.list(this.parmValue);
  446. if (res && res.code === 0 && res.data) {
  447. this.tableData = res.data.list;
  448. this.pageInfo.total = Number(res.data.count);
  449. } else if (res && res.code >= 100 && res.code <= 104) {
  450. await this.logout();
  451. } else {
  452. this.tableData = [];
  453. this.pageInfo.total = 0;
  454. }
  455. this.loading = false;
  456. },
  457. },
  458. };
  459. </script>
  460. <style lang="scss" scoped></style>