index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. placeholder="关键字类型"
  116. >
  117. <el-option label="活动名称" value="1" />
  118. <el-option label="活动编码" value="2" />
  119. <el-option label="创建人" value="3" /> </el-select
  120. ></el-input>
  121. </el-col>
  122. <el-col
  123. :span="3"
  124. class="fr"
  125. style="width: 66px; padding: 0 0 0 10px"
  126. v-if="powers.some((item) => item == '003')"
  127. >
  128. <el-button
  129. :size="searchSize"
  130. type="success"
  131. style="float: right"
  132. @click="routeGoto('activeDetail', { id: 'add', type: 'add' })"
  133. >
  134. 添加
  135. </el-button>
  136. </el-col>
  137. </el-row>
  138. </div></template
  139. >
  140. <template #status="{ scope }">
  141. <el-tag
  142. :size="tablebtnSize"
  143. :type="
  144. scope.row.status == '4'
  145. ? ''
  146. : scope.row.status == '8'
  147. ? 'danger'
  148. : scope.row.status == '5' || scope.row.status == '7'
  149. ? 'info'
  150. : 'warning'
  151. "
  152. v-text="
  153. (statusOptions.find((item) => item.id == scope.row.status) || {})
  154. .label || '--'
  155. "
  156. ></el-tag>
  157. </template>
  158. <template #atime="{ scope }">
  159. {{ scope.row.start }}~{{ scope.row.end }}
  160. </template>
  161. <template #operation="{ scope }">
  162. <el-tooltip
  163. v-if="powers.some((item) => item == '007')"
  164. effect="dark"
  165. content="详情"
  166. placement="top"
  167. >
  168. <i
  169. class="el-icon-view tb-icon"
  170. @click="
  171. routeGoto('activeDetail', {
  172. id: scope.row.activity_code,
  173. type: 'view',
  174. })
  175. "
  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. this.searchList();
  264. },
  265. methods: {
  266. restSearch() {
  267. // 表格 - 分页
  268. this.pageInfo = {
  269. size: 15,
  270. curr: 1,
  271. total: 0,
  272. };
  273. this.parmValue = {
  274. activity_name: "",
  275. activity_code: "",
  276. status: "",
  277. platform_code: [],
  278. starttime: "",
  279. endtime: "",
  280. page: 1, // 页码
  281. size: 15, // 每页显示条数
  282. company_id: "",
  283. creater: "",
  284. };
  285. this.searchList();
  286. },
  287. async platform_codesearchChange(e) {
  288. const { id, code, label } = e;
  289. this.parmValue.platform_code = id ? [id] : [];
  290. this.pageInfo.curr = 1;
  291. this.parmValue.page = 1;
  292. await this.searchList();
  293. },
  294. async company_idsearchChange(e) {
  295. const { id, code, label } = e;
  296. this.parmValue.company_id = code || "";
  297. this.pageInfo.curr = 1;
  298. this.parmValue.page = 1;
  299. await this.searchList();
  300. },
  301. // 新建/编辑/详情
  302. openModal(row, type) {
  303. this.sitem = row;
  304. this.modelId = type;
  305. this.showModel = true;
  306. },
  307. // 时间
  308. async handleTime(e) {
  309. this.parmValue.starttime = e.startTime || "";
  310. this.parmValue.endtime = e.endTime || "";
  311. if (
  312. (this.parmValue.starttime !== "" && this.parmValue.endtime !== "") ||
  313. (this.parmValue.starttime === "" && this.parmValue.endtime === "")
  314. ) {
  315. this.pageInfo.curr = 1;
  316. this.parmValue.page = 1;
  317. await this.searchList();
  318. }
  319. },
  320. /**
  321. * 启用/禁用
  322. * @param {String} id id
  323. * @param {String} status 0-禁用 1-启用
  324. */
  325. async changeStatus(id, status) {
  326. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  327. confirmButtonText: "确定",
  328. cancelButtonText: "取消",
  329. type: "warning",
  330. })
  331. .then(async () => {
  332. this.loading = true;
  333. const model = {
  334. id: id,
  335. status: status === "1" ? "0" : "1",
  336. };
  337. const res = await asyncRequest.status(model);
  338. if (res && res.code === 0) {
  339. this.loading = false;
  340. this.$notify.success({
  341. title: "状态修改成功!",
  342. message: "",
  343. });
  344. await this.searchList();
  345. } else if (res && res.code >= 100 && res.code <= 104) {
  346. await this.logout();
  347. } else {
  348. this.loading = false;
  349. this.$message.warning(res.message);
  350. }
  351. })
  352. .catch(() => {
  353. console.log("取消");
  354. });
  355. },
  356. async deleteItem(id) {
  357. await this.$confirm("确定要删除?", {
  358. confirmButtonText: "确定",
  359. cancelButtonText: "取消",
  360. type: "warning",
  361. })
  362. .then(async () => {
  363. const model = {
  364. id: id,
  365. };
  366. const res = await asyncRequest.delete(model);
  367. if (res && res.code === 0) {
  368. this.$notify.success({
  369. title: "删除成功",
  370. message: "",
  371. });
  372. this.searchList();
  373. } else if (res && res.code >= 100 && res.code <= 104) {
  374. await this.logout();
  375. } else {
  376. this.$message.warning(res.message);
  377. }
  378. })
  379. .catch(() => {
  380. console.log("取消");
  381. });
  382. },
  383. // 刷新表格
  384. async searchList() {
  385. this.loading = true;
  386. let model = JSON.parse(JSON.stringify(this.parmValue));
  387. model.platform_code = model.platform_code.toString();
  388. model.activity_name = this.select === "1" ? this.sinput : "";
  389. model.activity_code = this.select === "2" ? this.sinput : "";
  390. model.creater = this.select === "3" ? this.sinput : "";
  391. const res = await asyncRequest.list(model);
  392. if (res && res.code === 0 && res.data) {
  393. this.tableData = res.data.list;
  394. this.pageInfo.total = Number(res.data.count);
  395. } else if (res && res.code >= 100 && res.code <= 104) {
  396. await this.logout();
  397. } else {
  398. this.tableData = [];
  399. this.pageInfo.total = 0;
  400. }
  401. this.loading = false;
  402. },
  403. },
  404. };
  405. </script>
  406. <style lang="scss" scoped>
  407. </style>