index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <div class="goodsOnline 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="4" style="width: 120px">
  28. <el-select
  29. v-model="parmValue.good_type"
  30. filterable
  31. clearable
  32. :size="searchSize"
  33. placeholder="是否定制"
  34. style="width: 100%"
  35. @change="
  36. pageInfo.curr = 1;
  37. parmValue.page = 1;
  38. searchList();
  39. "
  40. >
  41. <el-option
  42. v-for="item in options1"
  43. :key="'good_type' + item.id"
  44. :label="item.name"
  45. :value="item.id"
  46. />
  47. </el-select>
  48. </el-col>
  49. <el-col :span="6" style="width: 303px; padding: 0 0 0 10px">
  50. <period-date-picker
  51. :type="1"
  52. :width="'135px'"
  53. :size="searchSize"
  54. :start="parmValue.start"
  55. :end="parmValue.end"
  56. @timeReturned="handleTime"
  57. />
  58. </el-col>
  59. <el-col :span="6" style="width: 310px; padding: 0 0 0 10px">
  60. <good-class
  61. :value="parmValue.cat_id"
  62. @handleChange="goods_class_change"
  63. :disabled="false"
  64. :size="searchSize"
  65. :isDetail="false"
  66. :placeholder="'分类'"
  67. />
  68. </el-col>
  69. <el-col
  70. :span="3"
  71. class="fr"
  72. style="width: 66px; padding: 0 0 0 10px"
  73. >
  74. <el-button type="primary" :size="searchSize" @click="searchList">
  75. 刷新
  76. </el-button>
  77. </el-col>
  78. <el-col
  79. :span="3"
  80. class="fr"
  81. style="width: 66px; padding: 0 0 0 10px"
  82. >
  83. <el-button type="warning" :size="searchSize" @click="restSearch">
  84. 重置
  85. </el-button>
  86. </el-col>
  87. </el-row>
  88. <el-row>
  89. <el-col :span="4" style="width: 200px">
  90. <el-select
  91. v-model="parmValue.exam_status"
  92. filterable
  93. clearable
  94. :size="searchSize"
  95. placeholder="状态"
  96. style="width: 100%"
  97. @change="
  98. pageInfo.curr = 1;
  99. parmValue.page = 1;
  100. searchList();
  101. "
  102. >
  103. <el-option
  104. v-for="item in options8"
  105. :key="'status' + item.id"
  106. :label="item.name"
  107. :value="item.id"
  108. />
  109. </el-select>
  110. </el-col>
  111. <el-col :span="4" style="width: 240px; padding: 0 0 0 10px">
  112. <search-brand
  113. :value="brandid"
  114. :disabled="type === 'view' || type === 'editCoin'"
  115. :size="'mini'"
  116. :isDetail="type !== 'add'"
  117. :names="brand_name"
  118. :placeholder="'商品品牌'"
  119. @searchChange="brandidsearchChange"
  120. />
  121. </el-col>
  122. <el-col :span="4" style="width: 470px; padding: 0 0 0 10px">
  123. <el-input
  124. :size="searchSize"
  125. v-model="sinput"
  126. :maxlength="40"
  127. @blur="
  128. pageInfo.curr = 1;
  129. parmValue.page = 1;
  130. searchList();
  131. "
  132. placeholder="关键字"
  133. ><el-select
  134. v-model="select"
  135. slot="prepend"
  136. :size="searchSize"
  137. style="width: 140px"
  138. placeholder="关键字类型"
  139. >
  140. <el-option label="商品名称" value="1" />
  141. <el-option label="商品编号" value="2" />
  142. <!-- <el-option label="平台编号" value="3" /> -->
  143. <!-- <el-option label="供应商编号" value="4" /> -->
  144. <el-option label="业务企业编号" value="5" />
  145. <el-option label="平台商品编号" value="6" />
  146. <el-option label="创建人" value="7" /> </el-select
  147. ></el-input>
  148. </el-col>
  149. <el-col
  150. :span="3"
  151. class="fr"
  152. style="width: 66px; padding: 0 0 0 10px"
  153. v-if="powers.some((item) => item == '003')"
  154. >
  155. <el-button
  156. :size="searchSize"
  157. type="success"
  158. style="float: right"
  159. @click="routeGoto('goodsOnlineAdd', {})"
  160. >
  161. 添加
  162. </el-button>
  163. </el-col>
  164. </el-row>
  165. </div></template
  166. >
  167. <template #good_thumb_img="{ scope }">
  168. <div
  169. v-if="scope.row.good_thumb_img"
  170. style="width: 20px; height: 20px"
  171. class="hover"
  172. v-viewer
  173. >
  174. <img
  175. :src="scope.row.good_thumb_img"
  176. style="display: inline-block; width: 100%; height: 100%"
  177. alt=""
  178. />
  179. </div>
  180. </template>
  181. <template #status="{ scope }">
  182. <el-tag
  183. :size="tablebtnSize"
  184. :type="
  185. scope.row.status == '6'
  186. ? ''
  187. : scope.row.status == '7'
  188. ? 'danger'
  189. : 'warning'
  190. "
  191. v-text="
  192. (options8.find((item) => item.id == scope.row.status) || {}).name ||
  193. '--'
  194. "
  195. ></el-tag>
  196. </template>
  197. <template #good_type="{ scope }">
  198. <el-tag
  199. :size="tablebtnSize"
  200. :type="scope.row.good_type == '0' ? 'warning' : ''"
  201. v-text="
  202. (options1.find((item) => item.id == scope.row.good_type) || {})
  203. .name || '--'
  204. "
  205. ></el-tag>
  206. </template>
  207. <template #operation="{ scope }">
  208. <el-tooltip
  209. v-if="powers.some((item) => item == '007')"
  210. effect="dark"
  211. content="详情"
  212. placement="top"
  213. >
  214. <i
  215. class="el-icon-view tb-icon"
  216. @click="
  217. routeGoto('goodsOnlineDetail', {
  218. id: scope.row.skuCode,
  219. type: 'view',
  220. })
  221. "
  222. ></i>
  223. </el-tooltip>
  224. <el-tooltip
  225. v-if="
  226. powers.some((item) => item == '078') &&
  227. (scope.row.status === '7' || scope.row.status === '8')
  228. "
  229. effect="dark"
  230. content="重新发起上线流程"
  231. placement="top"
  232. >
  233. <i
  234. class="el-icon-upload tb-icon"
  235. @click="get_againonline(scope.row.skuCode)"
  236. ></i>
  237. </el-tooltip>
  238. <el-tooltip
  239. v-if="
  240. powers.some((item) => item == '079') && scope.row.status !== '8'
  241. "
  242. effect="dark"
  243. content="下线商品"
  244. placement="top"
  245. >
  246. <i
  247. class="el-icon-download tb-icon"
  248. @click="get_donline(scope.row.skuCode)"
  249. ></i>
  250. </el-tooltip>
  251. </template>
  252. </ex-table>
  253. <no-auth v-else></no-auth>
  254. <!-- 弹窗 新增/修改 -->
  255. <add-edit
  256. :id="modelId"
  257. :show-model="showModel"
  258. :sitem="sitem"
  259. @refresh="searchList"
  260. @cancel="showModel = false"
  261. />
  262. </div>
  263. </template>
  264. <script>
  265. import asyncRequest from "@/apis/service/goodStore/goodsOnline";
  266. import mixinPage from "@/mixins/elPaginationHandle";
  267. import { mapGetters } from "vuex";
  268. import resToken from "@/mixins/resToken";
  269. import { listCol, options1, options8 } from "./columns";
  270. export default {
  271. name: "goodsOnline",
  272. mixins: [mixinPage, resToken],
  273. computed: {
  274. //组件SIZE设置
  275. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  276. powers() {
  277. let tran =
  278. this.$store.getters.btnList.find(
  279. (item) => item.menu_route == "goodsOnline"
  280. ) || {};
  281. if (tran && tran.action && tran.action.length > 0) {
  282. return tran.action;
  283. } else {
  284. return [];
  285. }
  286. },
  287. },
  288. data() {
  289. return {
  290. options1: options1,
  291. options8: options8,
  292. loading: false,
  293. parmValue: {
  294. good_name: "", //商品名称
  295. spucode: "", //商品编号
  296. cat_id: "", //商品分类
  297. start: "", //开始日期
  298. end: "", //结束日期
  299. platform_code: "", //平台编码
  300. is_stock: "", //是否库存品
  301. page: 1, // 页码
  302. size: 15, // 每页显示条数
  303. supplierNo: "", //供应商编号
  304. good_type: "", //是否定制
  305. brand_id: "", //品牌
  306. companyNo: "", //业务企业编号
  307. exam_status: "", //审核状态
  308. plat_code: "", //平台商品编号
  309. creater: "", //
  310. },
  311. // 表格 - 数据
  312. tableData: [],
  313. // 表格 - 参数
  314. table: {
  315. stripe: true,
  316. border: true,
  317. _defaultHeader_: ["setcol"],
  318. },
  319. // 表格 - 分页
  320. pageInfo: {
  321. size: 15,
  322. curr: 1,
  323. total: 0,
  324. },
  325. // 表格 - 列参数
  326. columns: listCol,
  327. cat_id: [],
  328. brandid: [],
  329. select: "1",
  330. sinput: "",
  331. };
  332. },
  333. mounted() {
  334. this.cat_id = [];
  335. this.brandid = [];
  336. this.searchList();
  337. },
  338. methods: {
  339. restSearch() {
  340. this.cat_id = [];
  341. this.brandid = [];
  342. // 表格 - 分页
  343. this.pageInfo = {
  344. size: 15,
  345. curr: 1,
  346. total: 0,
  347. };
  348. this.parmValue = {
  349. good_name: "", //商品名称
  350. spucode: "", //商品编号
  351. cat_id: "", //商品分类
  352. start: "", //开始日期
  353. end: "", //结束日期
  354. platform_code: "", //平台编码
  355. is_stock: "", //是否库存品
  356. page: 1, // 页码
  357. size: 15, // 每页显示条数
  358. supplierNo: "", //供应商编号
  359. good_type: "", //是否定制
  360. brand_id: "", //品牌
  361. companyNo: "", //业务企业编号
  362. exam_status: "", //审核状态
  363. plat_code: "", //平台商品编号
  364. creater: "", //
  365. };
  366. this.searchList();
  367. },
  368. //商品品牌选择
  369. async brandidsearchChange(e) {
  370. const { id, code, label } = e;
  371. if (id) {
  372. this.brandid = [id];
  373. } else {
  374. this.brandid = [];
  375. }
  376. this.parmValue.brand_id = this.brandid.toString();
  377. this.pageInfo.curr = 1;
  378. this.parmValue.page = 1;
  379. await this.searchList();
  380. },
  381. // 时间
  382. async handleTime(e) {
  383. this.parmValue.start = e.startTime || "";
  384. this.parmValue.end = e.endTime || "";
  385. if (
  386. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  387. (this.parmValue.start === "" && this.parmValue.end === "")
  388. ) {
  389. this.pageInfo.curr = 1;
  390. this.parmValue.page = 1;
  391. await this.searchList();
  392. }
  393. },
  394. /**
  395. * 商品重新上线
  396. * @param {String} id id
  397. * @param {String} status 0-禁用 1-启用
  398. */
  399. async get_againonline(skuCode) {
  400. await this.$confirm(`确定要重新发起上线流程?`, {
  401. confirmButtonText: "确定",
  402. cancelButtonText: "取消",
  403. type: "warning",
  404. })
  405. .then(async () => {
  406. this.loading = true;
  407. const model = {
  408. skuCode: skuCode,
  409. };
  410. const res = await asyncRequest.againonline(model);
  411. if (res && res.code === 0) {
  412. this.loading = false;
  413. this.$notify.success({
  414. title: "重新发起上线流程成功!",
  415. message: "",
  416. });
  417. await this.searchList();
  418. } else if (res && res.code >= 100 && res.code <= 104) {
  419. await this.logout();
  420. } else {
  421. this.loading = false;
  422. this.$message.warning(res.message);
  423. }
  424. })
  425. .catch(() => {
  426. console.log("取消");
  427. });
  428. },
  429. /**
  430. * 商品下线
  431. * @param {String} id id
  432. * @param {String} status 0-禁用 1-启用
  433. */
  434. async get_donline(skuCode) {
  435. await this.$confirm(`确定要下线商品?`, {
  436. confirmButtonText: "确定",
  437. cancelButtonText: "取消",
  438. type: "warning",
  439. })
  440. .then(async () => {
  441. this.loading = true;
  442. const model = {
  443. skuCode: skuCode,
  444. exam_status: "8",
  445. };
  446. const res = await asyncRequest.status(model);
  447. if (res && res.code === 0) {
  448. this.loading = false;
  449. this.$notify.success({
  450. title: "下线商品成功!",
  451. message: "",
  452. });
  453. await this.searchList();
  454. } else if (res && res.code >= 100 && res.code <= 104) {
  455. await this.logout();
  456. } else {
  457. this.loading = false;
  458. this.$message.warning(res.message);
  459. }
  460. })
  461. .catch(() => {
  462. console.log("取消");
  463. });
  464. },
  465. /**
  466. * 启用/禁用
  467. * @param {String} id id
  468. * @param {String} status 0-禁用 1-启用
  469. */
  470. async changeStatus(id, status) {
  471. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  472. confirmButtonText: "确定",
  473. cancelButtonText: "取消",
  474. type: "warning",
  475. })
  476. .then(async () => {
  477. this.loading = true;
  478. const model = {
  479. id: id,
  480. status: status === "1" ? "0" : "1",
  481. };
  482. const res = await asyncRequest.status(model);
  483. if (res && res.code === 0) {
  484. this.loading = false;
  485. this.$notify.success({
  486. title: "状态修改成功!",
  487. message: "",
  488. });
  489. await this.searchList();
  490. } else if (res && res.code >= 100 && res.code <= 104) {
  491. await this.logout();
  492. } else {
  493. this.loading = false;
  494. this.$message.warning(res.message);
  495. }
  496. })
  497. .catch(() => {
  498. console.log("取消");
  499. });
  500. },
  501. async deleteItem(code) {
  502. await this.$confirm("确定要删除?", {
  503. confirmButtonText: "确定",
  504. cancelButtonText: "取消",
  505. type: "warning",
  506. })
  507. .then(async () => {
  508. const model = {
  509. codes: [code],
  510. };
  511. const res = await asyncRequest.delete(model);
  512. if (res && res.code === 0) {
  513. this.$notify.success({
  514. title: "删除成功",
  515. message: "",
  516. });
  517. this.searchList();
  518. } else if (res && res.code >= 100 && res.code <= 104) {
  519. await this.logout();
  520. } else {
  521. this.$message.warning(res.message);
  522. }
  523. })
  524. .catch(() => {
  525. console.log("取消");
  526. });
  527. },
  528. // 刷新表格
  529. async searchList() {
  530. if (
  531. (this.parmValue.start !== "" && this.parmValue.end === "") ||
  532. (this.parmValue.start === "" && this.parmValue.end !== "")
  533. ) {
  534. this.$message.warning("时间区间不完整!");
  535. return;
  536. }
  537. this.loading = true;
  538. let model = JSON.parse(JSON.stringify(this.parmValue));
  539. model.good_name = this.select === "1" ? this.sinput : ""; //商品名称
  540. model.spucode = this.select === "2" ? this.sinput : ""; //商品编号
  541. // model.platform_code = this.select === "1" ? this.sinput : ""; //平台编码
  542. // model.supplierNo = this.select === "1" ? this.sinput : ""; //供应商编号
  543. model.companyNo = this.select === "5" ? this.sinput : ""; //业务企业编号
  544. // model.exam_status = this.select === "1" ? this.sinput : ""; //审核状态
  545. model.plat_code = this.select === "6" ? this.sinput : ""; //平台商品编号
  546. model.creater = this.select === "7" ? this.sinput : ""; //
  547. const res = await asyncRequest.list(model);
  548. if (res && res.code === 0 && res.data) {
  549. this.tableData = res.data.list;
  550. this.tableData.forEach((a) => {
  551. a.cat_name = "";
  552. let list = a.cat_info || [];
  553. list.forEach((b, i) => {
  554. a.cat_name += i == 0 ? b.name : "/" + b.name;
  555. });
  556. });
  557. this.pageInfo.total = Number(res.data.count);
  558. } else if (res && res.code >= 100 && res.code <= 104) {
  559. await this.logout();
  560. } else {
  561. this.tableData = [];
  562. this.pageInfo.total = 0;
  563. }
  564. this.loading = false;
  565. },
  566. //商品分类选择
  567. async goods_class_change(e) {
  568. this.cat_id = e;
  569. this.parmValue.cat_id =
  570. this.cat_id.length === 0 ? "" : this.cat_id[this.cat_id.length - 1];
  571. this.pageInfo.curr = 1;
  572. this.parmValue.page = 1;
  573. await this.searchList();
  574. },
  575. },
  576. };
  577. </script>
  578. <style lang="scss" scoped>
  579. </style>