index.vue 18 KB

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