index.vue 18 KB

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