index.vue 13 KB

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