index.vue 13 KB

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