index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <template>
  2. <div class="goodsCost pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers.some((i) => i == '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. @selection="selection_change"
  24. >
  25. <template #table-header="{}">
  26. <div style="width: 100%">
  27. <el-row style="padding: 0 0 10px 80px">
  28. <el-col :span="6" style="width: 303px">
  29. <period-date-picker
  30. :type="1"
  31. :width="'135px'"
  32. :size="searchSize"
  33. :start="parmValue.start"
  34. :end="parmValue.end"
  35. @timeReturned="handleTime"
  36. />
  37. </el-col>
  38. <el-col :span="4" style="width: 135px">
  39. <search-brand
  40. :value="brandid"
  41. :disabled="false"
  42. :size="'mini'"
  43. :isDetail="true"
  44. :names="parmValue.supplierName"
  45. :placeholder="'商品品牌'"
  46. @searchChange="brandidsearchChange"
  47. />
  48. </el-col>
  49. <el-col :span="6" style="width: 310px; padding: 0 0 0 10px">
  50. <good-class
  51. :value="parmValue.cat_id"
  52. @handleChange="goods_class_change"
  53. :disabled="false"
  54. :size="searchSize"
  55. :isDetail="false"
  56. :placeholder="'分类'"
  57. />
  58. </el-col>
  59. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  60. <el-button type="primary" :size="searchSize" @click="searchList">刷新</el-button>
  61. </el-col>
  62. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  63. <el-button type="warning" :size="searchSize" @click="restSearch">重置</el-button>
  64. </el-col>
  65. </el-row>
  66. <el-row>
  67. <el-col :span="4" style="width: 226px">
  68. <el-select
  69. v-model="parmValue.status"
  70. filterable
  71. clearable
  72. :size="searchSize"
  73. placeholder="状态"
  74. style="width: 100%"
  75. @change="
  76. pageInfo.curr = 1;
  77. parmValue.page = 1;
  78. searchList();
  79. "
  80. >
  81. <el-option
  82. v-for="item in statusList"
  83. :key="'status' + item.code"
  84. :label="item.name"
  85. :value="item.code"
  86. />
  87. </el-select>
  88. </el-col>
  89. <el-col :span="4" style="width: 145px; padding: 0 0 0 10px">
  90. <el-select
  91. v-model="parmValue.isonline"
  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 isonlineoptions"
  105. :key="'isonline' + item.id"
  106. :label="item.name"
  107. :value="item.id"
  108. />
  109. </el-select>
  110. </el-col>
  111. <el-col :span="4" style="width: 135px;margin-left:10px">
  112. <el-select
  113. v-model="parmValue.is_stock"
  114. size="mini"
  115. style="width: 100%"
  116. placeholder="商品类型"
  117. clearable
  118. @change="
  119. pageInfo.curr = 1;
  120. parmValue.page = 1;
  121. searchList();
  122. "
  123. >
  124. <el-option
  125. v-for="opt in isStockOptions"
  126. :key="opt.value"
  127. :value="opt.value"
  128. :label="opt.label"
  129. />
  130. </el-select>
  131. </el-col>
  132. <el-col :span="3" style="margin: 0 10px">
  133. <search-supplier
  134. :size="'mini'"
  135. style="width: 300px"
  136. :value="supplierNo"
  137. :disabled="false"
  138. :placeholder="'供应商名称'"
  139. :names="''"
  140. :isDetail="false"
  141. :noDisabled="true"
  142. @searchChange="supplierChange"
  143. />
  144. </el-col>
  145. <el-col
  146. :span="3"
  147. class="fr"
  148. style="width: 66px; padding: 0 0 0 10px"
  149. v-if="powers.some((i) => i == '003') && !isSupertube"
  150. >
  151. <el-button
  152. :size="searchSize"
  153. type="success"
  154. style="float: right"
  155. @click="handleCreate"
  156. >添加</el-button>
  157. </el-col>
  158. <el-col
  159. :span="3"
  160. class="fr"
  161. style="width: 110px; padding: 0 0 0 10px"
  162. v-if="powers.some((i) => i == '055') && !isSupertube"
  163. >
  164. <el-button :size="searchSize" type="warning" style="float: right" @click="add_online">
  165. <i class="el-icon-circle-plus-outline"></i>
  166. <span>商品上线</span>
  167. </el-button>
  168. </el-col>
  169. </el-row>
  170. <el-row style="margin-top: 10px">
  171. <el-col :span="4" style="width: 370px">
  172. <el-input
  173. :size="searchSize"
  174. v-model="sinput"
  175. :maxlength="40"
  176. @blur="
  177. pageInfo.curr = 1;
  178. parmValue.page = 1;
  179. searchList();
  180. "
  181. placeholder="关键字"
  182. >
  183. <el-select
  184. v-model="select"
  185. slot="prepend"
  186. style="width: 135px"
  187. @change="
  188. pageInfo.curr = 1;
  189. parmValue.page = 1;
  190. searchList();
  191. "
  192. placeholder="关键字类型"
  193. >
  194. <el-option label="商品编号" value="1" />
  195. <el-option label="商品名称" value="2" />
  196. </el-select>
  197. </el-input>
  198. </el-col>
  199. <el-col :span="3" style="margin-left:10px">
  200. <el-select
  201. clearable
  202. v-model="parmValue.is_combind"
  203. placeholder="组合类型"
  204. style="width:225px"
  205. size="mini"
  206. @change="
  207. pageInfo.curr = 1;
  208. parmValue.page = 1;
  209. searchList();
  210. "
  211. >
  212. <el-option label="组合商品" value="1" />
  213. <el-option label="非组合商品" value="0" />
  214. </el-select>
  215. </el-col>
  216. </el-row>
  217. </div>
  218. </template>
  219. <template #spuCode="{ scope }">
  220. <div style="display:flex;align-items:center">
  221. <p>{{scope.row.spuCode}}</p>
  222. </div>
  223. </template>
  224. <template #good_thumb_img="{ scope }">
  225. <div
  226. v-if="scope.row.good_thumb_img"
  227. style="width: 20px; height: 20px"
  228. class="hover"
  229. v-viewer
  230. >
  231. <img
  232. :src="scope.row.good_thumb_img"
  233. style="display: inline-block; width: 100%; height: 100%"
  234. alt
  235. />
  236. </div>
  237. </template>
  238. <template #status="{ scope }">
  239. <el-tag
  240. :size="tablebtnSize"
  241. :type="
  242. (statusList.find((item) => item.code == scope.row.status) || {}).type || '--'
  243. "
  244. v-text="
  245. (statusList.find((item) => item.code == scope.row.status) || {}).name || '--'
  246. "
  247. ></el-tag>
  248. </template>
  249. <template #has_account="{ scope }">
  250. <el-tag
  251. :size="tablebtnSize"
  252. :type="
  253. (
  254. has_account_list.find((item) => item.code == scope.row.has_account + '') ||
  255. {}
  256. ).type || '--'
  257. "
  258. v-text="
  259. (
  260. has_account_list.find((item) => item.code == scope.row.has_account + '') ||
  261. {}
  262. ).name || '--'
  263. "
  264. ></el-tag>
  265. </template>
  266. <template #is_combind="{ scope }">
  267. <el-tag
  268. size="mini"
  269. :type="scope.row.is_combind === '1' ? '' : 'warning'"
  270. >{{scope.row.is_combind === '1' ? '组合商品' : '非组合商品'}}</el-tag>
  271. </template>
  272. <template #isonline="{ scope }">
  273. <el-tag
  274. :size="tablebtnSize"
  275. :type="scope.row.is_online == '0' ? 'warning' : ''"
  276. v-text="
  277. (isonlineoptions.find((item) => item.id == scope.row.is_online) || {}).name ||
  278. '--'
  279. "
  280. ></el-tag>
  281. </template>
  282. <template #is_stock="{ scope }">
  283. <el-tag
  284. :size="tablebtnSize"
  285. :type="scope.row.is_stock == '0' ? 'warning' : ''"
  286. v-text="
  287. (options4.find((item) => item.id == scope.row.is_stock) || {}).name || '--'
  288. "
  289. ></el-tag>
  290. </template>
  291. <template #operation="{ scope }">
  292. <el-tooltip
  293. v-if="powers.some((i) => i == '007') && scope.row.status !== '8'"
  294. effect="dark"
  295. content="详情"
  296. placement="top"
  297. >
  298. <i class="el-icon-view tb-icon" @click="getRouter('goodsCostDetail', scope.row.spuCode)"></i>
  299. </el-tooltip>
  300. <el-tooltip
  301. v-if="
  302. powers.some((i) => i == '079') && scope.row.status !== '8' && !isSupertube
  303. "
  304. effect="dark"
  305. content="下线商品"
  306. placement="top"
  307. >
  308. <i class="el-icon-download tb-icon" @click="showDonlineDlg(scope.row.spuCode)"></i>
  309. </el-tooltip>
  310. <!-- scope.row.has_account + '' == '0' && -->
  311. <el-tooltip
  312. v-if="
  313. (((ppowers.some((i) => i == '7') && scope.row.status + '' === '7') ||
  314. (ppowers.some((i) => i == '6') && scope.row.status + '' === '6') ||
  315. (ppowers.some((i) => i == '8') && scope.row.status + '' === '8')) &&
  316. (scope.row.is_stock + '' === '0' || scope.row.is_stock + '' === '1')) &&
  317. !isSupertube && String(scope.row.has_account) === '0'
  318. "
  319. effect="dark"
  320. content="修改"
  321. placement="top"
  322. >
  323. <i
  324. class="el-icon-edit tb-icon"
  325. @click="
  326. routeGoto('goodsCostDetail', {
  327. id: scope.row.spuCode,
  328. type: 'edit',
  329. })
  330. "
  331. ></i>
  332. </el-tooltip>
  333. <el-tooltip
  334. v-if="
  335. (ppowers.some((i) => i == '4') &&
  336. (scope.row.status + '' === '4' || scope.row.status + '' === '1') &&
  337. (scope.row.is_stock + '' === '0' || scope.row.is_stock + '' === '1')) &&
  338. !isSupertube && String(scope.row.has_account) === '0'
  339. "
  340. effect="dark"
  341. content="修改基础信息"
  342. placement="top"
  343. >
  344. <i
  345. class="el-icon-c-scale-to-original tb-icon"
  346. @click="wantto(scope.row.is_online, scope.row.spuCode, scope.row.status, '2')"
  347. ></i>
  348. </el-tooltip>
  349. <!-- scope.row.has_account + '' == '0' && -->
  350. <el-tooltip
  351. v-if="
  352. (ppowers.some((i) => i == '5') &&
  353. (scope.row.status + '' === '5' || scope.row.status + '' === '1') &&
  354. (scope.row.is_stock + '' === '0' || scope.row.is_stock + '' === '1')) &&
  355. !isSupertube && String(scope.row.has_account) === '0'
  356. "
  357. effect="dark"
  358. content="修改成本信息"
  359. placement="top"
  360. >
  361. <i
  362. class="el-icon-coin tb-icon"
  363. @click="wantto(scope.row.is_online, scope.row.spuCode, scope.row.status, '3')"
  364. ></i>
  365. </el-tooltip>
  366. <el-tooltip
  367. v-if="
  368. powers.some((i) => i == '010') &&
  369. !(scope.row.status + '' === '7' || scope.row.status + '' === '8') &&
  370. !isSupertube &&
  371. String(scope.row.createrid) !== '0'
  372. "
  373. effect="dark"
  374. content="复制商品"
  375. placement="top"
  376. >
  377. <i class="el-icon-document-copy tb-icon" @click="good_copy(scope.row.spuCode)"></i>
  378. </el-tooltip>
  379. <el-tooltip
  380. v-if="powers.some((i) => i == '006') && !isSupertube"
  381. effect="dark"
  382. content="删除"
  383. placement="top"
  384. >
  385. <i class="el-icon-delete tb-icon" @click="deleteItem(scope.row.spuCode)"></i>
  386. </el-tooltip>
  387. </template>
  388. </ex-table>
  389. <no-auth v-else></no-auth>
  390. <el-dialog title="下线原因" :visible.sync="dialogFormVisible" width="500px">
  391. <el-form
  392. :model="donline_form"
  393. :rules="donline_rules"
  394. ref="donline_Form"
  395. class="demo-ruleForm"
  396. label-width="80px"
  397. >
  398. <el-form-item label="下线原因" prop="offline_reason">
  399. <el-select
  400. style="width: 100%"
  401. v-model="donline_form.offline_reason"
  402. placeholder="请选择下线原因"
  403. >
  404. <el-option
  405. :label="item.result"
  406. :value="item.result_code"
  407. v-for="item in donline_formStOps"
  408. :key="item.result_code"
  409. ></el-option>
  410. </el-select>
  411. </el-form-item>
  412. <el-form-item label="下线备注" prop="offline_remark">
  413. <el-input
  414. v-model="donline_form.offline_remark"
  415. type="textarea"
  416. placeholder="请输入下线备注"
  417. autocomplete="off"
  418. ></el-input>
  419. </el-form-item>
  420. </el-form>
  421. <div slot="footer" class="dialog-footer">
  422. <el-button @click="dialogFormVisible = false">取 消</el-button>
  423. <el-button type="primary" @click="donlineDlg">确 定</el-button>
  424. </div>
  425. </el-dialog>
  426. <add-edit
  427. :id="''"
  428. :isNobleMetal="isNobleMetal"
  429. :sitem="changeList"
  430. :show-model="showModel"
  431. :is-detail="false"
  432. @refresh="showModel = false"
  433. @cancel="showModel = false"
  434. />
  435. </div>
  436. </template>
  437. <script>
  438. import asyncRequest from "@/apis/service/goodStore/goodsCost";
  439. import { listCol, options1, options4 } from "./columns";
  440. import { has_account_list, isStockOptions } from "@/assets/js/statusList";
  441. import mixinPage from "@/mixins/elPaginationHandle";
  442. import resToken from "@/mixins/resToken";
  443. import companyHelper from "@/mixins/companyHelper";
  444. import addEdit from "./components/addEdit";
  445. import { mapGetters } from "vuex";
  446. export default {
  447. name: "goodsCost",
  448. mixins: [mixinPage, resToken, companyHelper],
  449. components: {
  450. addEdit
  451. },
  452. computed: {
  453. //组件SIZE设置
  454. ...mapGetters(["tablebtnSize", "searchSize", "size", "isSupertube"]),
  455. powers() {
  456. const tran =
  457. this.$store.getters.btnList.find(i => i.menu_route == "goodsCost") ||
  458. {};
  459. const { action } = tran ?? {};
  460. return action ?? [];
  461. },
  462. ppowers() {
  463. const tran =
  464. this.$store.getters.roleProcess.find(i => i.process_type === "SPCB") ||
  465. {};
  466. const { action } = tran ?? {};
  467. console.log(action);
  468. return action || [];
  469. }
  470. },
  471. data() {
  472. var validate = (rule, value, callback) => {
  473. if (value == "") {
  474. return callback(new Error("必填项不能为空"));
  475. } else {
  476. callback();
  477. }
  478. };
  479. return {
  480. isNobleMetal: false,
  481. dialogFormVisible: false,
  482. has_account_list,
  483. donline_formStOps: [],
  484. isStockOptions,
  485. donline_form: {
  486. offline_reason: "",
  487. offline_remark: "",
  488. spuCode: ""
  489. },
  490. donline_rules: {
  491. offline_reason: [
  492. { validator: validate, required: true, trigger: "blur" }
  493. ],
  494. offline_remark: [
  495. { validator: validate, required: true, trigger: "blur" }
  496. ]
  497. },
  498. statusList: [
  499. {
  500. code: "0",
  501. name: "新建待审核",
  502. type: ""
  503. },
  504. {
  505. code: "1",
  506. name: "审核通过",
  507. type: "success"
  508. },
  509. {
  510. code: "2",
  511. name: "基础修改待审核",
  512. type: ""
  513. },
  514. {
  515. code: "3",
  516. name: "成本修改待审核",
  517. type: ""
  518. },
  519. {
  520. code: "4",
  521. name: "基础修改驳回",
  522. type: "danger"
  523. },
  524. {
  525. code: "5",
  526. name: "成本修改驳回",
  527. type: "danger"
  528. },
  529. {
  530. code: "6",
  531. name: "新建审核驳回",
  532. type: "danger"
  533. },
  534. {
  535. code: "7",
  536. name: "复制商品待编辑",
  537. type: "info"
  538. },
  539. {
  540. code: "8",
  541. name: "竞价商品待编辑",
  542. type: "info"
  543. }
  544. ],
  545. isonlineoptions: [
  546. { id: "0", name: "未上线" },
  547. { id: "1", name: "已上线" }
  548. ],
  549. showModel: false,
  550. options1,
  551. options4,
  552. loading: false,
  553. changeList: [],
  554. parmValue: {
  555. page: 1, // 页码
  556. size: 15, // 每页显示条数
  557. is_combind: "",
  558. is_stock: "",
  559. start: "",
  560. end: "",
  561. status: "",
  562. good_name: "",
  563. spucode: "",
  564. cat_id: [],
  565. brandid: "",
  566. good_type: "",
  567. companyNo: "",
  568. supplierNo: "",
  569. isonline: "",
  570. company_name: "" //创建人部门
  571. // creater: "",
  572. },
  573. sinput: "",
  574. select: "",
  575. // 表格 - 数据
  576. tableData: [],
  577. // 表格 - 参数
  578. table: {
  579. stripe: true,
  580. border: true,
  581. _defaultHeader_: ["setcol"]
  582. },
  583. // 表格 - 分页
  584. pageInfo: {
  585. size: 15,
  586. curr: 1,
  587. total: 0
  588. },
  589. // 表格 - 列参数
  590. columns: listCol,
  591. supplierNo: [],
  592. brandid: []
  593. };
  594. },
  595. mounted() {
  596. const { back } = this.$route.query;
  597. if (back) {
  598. this.parmValue = JSON.parse(back);
  599. const { page, size } = this.parmValue;
  600. // this.parmValue.start = start || last_start;
  601. // this.parmValue.end = end || last_end;
  602. if (this.parmValue.brandid.length > 0) {
  603. this.brandid = [this.parmValue.brandid];
  604. }
  605. this.pageInfo = {
  606. size: size,
  607. curr: page,
  608. total: 0
  609. };
  610. //多选条件
  611. this.select = this.parmValue.select;
  612. // this.sselect = this.parmValue.sselect;
  613. this.sinput = this.parmValue.sinput;
  614. } else {
  615. this.select = "2";
  616. // this.sselect = "创建时间"
  617. }
  618. this.select = "2";
  619. this.supplierNo = [];
  620. this.searchList();
  621. },
  622. methods: {
  623. handleCreate() {
  624. if (!this.currentIsBusinessCompany()) return;
  625. this.routeGoto("goodsCostDetail", { id: "add", type: "add" });
  626. },
  627. async supplierChange(e) {
  628. const { code, label } = e;
  629. this.supplierNo = code ? [code] : [];
  630. this.searchList();
  631. },
  632. // 获取异常原因下拉列表
  633. async getresultlist() {
  634. const res = await asyncRequest.resultlist({
  635. page: 1,
  636. size: 100,
  637. type: "8",
  638. status: "3"
  639. });
  640. if (res && res.code === 0 && res.data) {
  641. const { list } = res.data;
  642. this.donline_formStOps = list;
  643. } else if (res && res.code >= 100 && res.code <= 104) {
  644. await this.logout();
  645. } else {
  646. this.$message.warning(res.message);
  647. }
  648. },
  649. getRouter(toRouter, queryId) {
  650. if (toRouter && queryId) {
  651. let model = {
  652. id: queryId,
  653. type: "view"
  654. };
  655. //有多选框的条件
  656. this.parmValue.select = this.select;
  657. this.parmValue.sinput = this.sinput;
  658. //
  659. let routerModel = {
  660. options: JSON.parse(JSON.stringify(this.parmValue)),
  661. router: this.$route.path
  662. };
  663. model.preModel = JSON.stringify(routerModel);
  664. this.routeGoto(toRouter, model);
  665. } else {
  666. this.$message.warning("暂未找到相关流程!");
  667. }
  668. },
  669. restSearch() {
  670. this.select = "2";
  671. this.sinput = "";
  672. this.supplierNo = [];
  673. this.brandid = [];
  674. // 表格 - 分页
  675. this.pageInfo = {
  676. size: 15,
  677. curr: 1,
  678. total: 0
  679. };
  680. this.parmValue = {
  681. page: 1, // 页码
  682. size: 15, // 每页显示条数
  683. start: "",
  684. end: "",
  685. status: "",
  686. good_name: "",
  687. company_name: "", //创建人部门
  688. spucode: "",
  689. cat_id: [],
  690. brandid: "",
  691. good_type: "",
  692. isonline: "",
  693. companyNo: "",
  694. supplierNo: "",
  695. is_combind: ""
  696. };
  697. this.searchList();
  698. },
  699. async wantto(isonline, spuCode, ntype, wtype) {
  700. const { code, data, message } = await asyncRequest.checkIsUpdate({
  701. spuCode
  702. });
  703. if (code === 0) {
  704. const { is_allow_update } = data;
  705. if (is_allow_update + "" === "1") {
  706. this.routeGoto("goodsCostDetail", {
  707. id: spuCode,
  708. type: wtype === "2" ? "editBase" : wtype === "3" ? "editCoin" : ""
  709. });
  710. } else {
  711. if (isonline + "" === "1") {
  712. this.$message.warning("已上线的商品需要下线才能修改!");
  713. } else {
  714. this.$message.warning("当前商品上线流程正在进行中,请下线再操作!");
  715. }
  716. }
  717. } else if (code >= 100 && code <= 104) {
  718. await this.logout();
  719. } else {
  720. this.$message.warning(message);
  721. }
  722. },
  723. selection_change(e) {
  724. const { list } = e;
  725. this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
  726. },
  727. //商品品牌选择
  728. async brandidsearchChange(e) {
  729. const { id, code, label } = e;
  730. if (id) {
  731. this.brandid = [id];
  732. this.parmValue.brandid = id;
  733. this.parmValue.supplierName = label;
  734. } else {
  735. this.brandid = [];
  736. this.parmValue.brandid = "";
  737. this.parmValue.supplierName = "";
  738. }
  739. // this.parmValue.brandid = this.brandid.toString();
  740. this.pageInfo.curr = 1;
  741. this.parmValue.page = 1;
  742. await this.searchList();
  743. },
  744. // 时间
  745. async handleTime(e) {
  746. this.parmValue.start = e.startTime || "";
  747. this.parmValue.end = e.endTime || "";
  748. if (
  749. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  750. (this.parmValue.start === "" && this.parmValue.end === "")
  751. ) {
  752. this.pageInfo.curr = 1;
  753. this.parmValue.page = 1;
  754. await this.searchList();
  755. }
  756. },
  757. async good_copy(spuCode) {
  758. await this.$confirm(`确定要复制该商品?`, {
  759. confirmButtonText: "确定",
  760. cancelButtonText: "取消",
  761. type: "warning"
  762. })
  763. .then(async () => {
  764. this.loading = true;
  765. const model = {
  766. spuCode: spuCode
  767. };
  768. const res = await asyncRequest.copy(model);
  769. if (res && res.code === 0) {
  770. this.loading = false;
  771. this.$notify.success({
  772. title: "复制商品成功!",
  773. message: ""
  774. });
  775. await this.searchList();
  776. } else if (res && res.code >= 100 && res.code <= 104) {
  777. await this.logout();
  778. } else {
  779. this.loading = false;
  780. this.$message.warning(res.message);
  781. }
  782. })
  783. .catch(() => {
  784. console.log("取消");
  785. });
  786. },
  787. /**
  788. * 启用/禁用
  789. * @param {String} id id
  790. * @param {String} status 0-禁用 1-启用
  791. */
  792. async changeStatus(id, status) {
  793. await this.$confirm(
  794. `确定要改为${status + "" === "1" ? "禁用" : "启用"}?`,
  795. {
  796. confirmButtonText: "确定",
  797. cancelButtonText: "取消",
  798. type: "warning"
  799. }
  800. )
  801. .then(async () => {
  802. this.loading = true;
  803. const model = {
  804. id: id,
  805. status: status + "" === "1" ? "0" : "1"
  806. };
  807. const res = await asyncRequest.status(model);
  808. if (res && res.code === 0) {
  809. this.loading = false;
  810. this.$notify.success({
  811. title: "状态修改成功!",
  812. message: ""
  813. });
  814. await this.searchList();
  815. } else if (res && res.code >= 100 && res.code <= 104) {
  816. await this.logout();
  817. } else {
  818. this.loading = false;
  819. this.$message.warning(res.message);
  820. }
  821. })
  822. .catch(() => {
  823. console.log("取消");
  824. });
  825. },
  826. async deleteItem(code) {
  827. await this.$confirm("确定要删除?", {
  828. confirmButtonText: "确定",
  829. cancelButtonText: "取消",
  830. type: "warning"
  831. })
  832. .then(async () => {
  833. const model = {
  834. codes: [code]
  835. };
  836. const res = await asyncRequest.delete(model);
  837. if (res && res.code === 0) {
  838. this.$notify.success({
  839. title: "删除成功",
  840. message: ""
  841. });
  842. this.searchList();
  843. } else if (res && res.code >= 100 && res.code <= 104) {
  844. await this.logout();
  845. } else {
  846. this.$message.warning(res.message);
  847. }
  848. })
  849. .catch(() => {
  850. console.log("取消");
  851. });
  852. },
  853. // 刷新表格
  854. async searchList() {
  855. if (
  856. (this.parmValue.start !== "" && this.parmValue.end === "") ||
  857. (this.parmValue.start === "" && this.parmValue.end !== "")
  858. ) {
  859. this.$message.warning("时间区间不完整!");
  860. return;
  861. }
  862. this.loading = true;
  863. let item = JSON.parse(JSON.stringify(this.parmValue));
  864. item.spucode = this.select === "1" ? this.sinput : "";
  865. item.good_name = this.select === "2" ? this.sinput : "";
  866. item.companyNo = this.select === "3" ? this.sinput : "";
  867. item.supplierNo = this.select === "4" ? this.sinput : "";
  868. item.company_name = this.select === "5" ? this.sinput : ""; // 部门
  869. item.cat_id =
  870. item.cat_id.length > 0 ? item.cat_id[item.cat_id.length - 1] : "";
  871. const res = await asyncRequest.list({
  872. ...item,
  873. supplierNo: Array.isArray(this.supplierNo) ? this.supplierNo[0] : "",
  874. needRela: true
  875. });
  876. if (res && res.code === 0 && res.data) {
  877. this.tableData = res.data.list;
  878. this.tableData.forEach(a => {
  879. a.cat_name = "";
  880. let list = a.cat_info || [];
  881. list.forEach((b, i) => {
  882. a.cat_name += i == 0 ? b.name : "/" + b.name;
  883. });
  884. });
  885. this.pageInfo.total = Number(res.data.count);
  886. } else if (res && res.code >= 100 && res.code <= 104) {
  887. await this.logout();
  888. } else {
  889. this.tableData = [];
  890. this.pageInfo.total = 0;
  891. }
  892. this.getresultlist();
  893. this.loading = false;
  894. },
  895. //商品分类选择
  896. async goods_class_change(e) {
  897. this.parmValue.cat_id = e;
  898. this.pageInfo.curr = 1;
  899. this.parmValue.page = 1;
  900. await this.searchList();
  901. },
  902. add_online() {
  903. if (this.changeList.length === 0) {
  904. this.$message.warning("至少选择一个商品!");
  905. return;
  906. }
  907. if (this.changeList.length > 100) {
  908. this.$message.warning("商品数量不能超过100!");
  909. return;
  910. }
  911. const categoryIds = this.changeList.map(
  912. ({ cat_info, is_gold_price }) => ({
  913. id: String(cat_info[0].id),
  914. isGoldPrice: String(is_gold_price)
  915. })
  916. );
  917. const nobleMetalIds = categoryIds.filter(
  918. ({ id, isGoldPrice }) => id === "6" && isGoldPrice === "1"
  919. );
  920. if (
  921. nobleMetalIds.length > 0 &&
  922. categoryIds.length !== nobleMetalIds.length
  923. ) {
  924. const h = this.$createElement;
  925. this.$message({
  926. message: h("p", null, [
  927. h("span", null, "勾选商品必须全部为"),
  928. h("i", { style: "color: red" }, "开启实时金价贵金属商品"),
  929. h("span", null, "或者全部为"),
  930. h(
  931. "i",
  932. { style: "color: red" },
  933. "未开启实时金价的贵金属商品和非贵金属商品"
  934. )
  935. ]),
  936. type: "warning",
  937. dangerouslyUseHTMLString: true
  938. });
  939. return;
  940. }
  941. this.isNobleMetal =
  942. nobleMetalIds.length > 0 && categoryIds.length === nobleMetalIds.length;
  943. let isok = true;
  944. this.changeList.forEach(e => {
  945. if (String(e.status) !== "1") {
  946. isok = false;
  947. }
  948. });
  949. if (!isok) {
  950. this.$message.warning("只有审核通过的商品可以上线!");
  951. return;
  952. }
  953. this.showModel = true;
  954. },
  955. //点击下线
  956. async showDonlineDlg(spuCode) {
  957. this.dialogFormVisible = true;
  958. this.donline_form = {
  959. offline_reason: "",
  960. offline_remark: "",
  961. skuCode: ""
  962. };
  963. this.donline_form.spuCode = spuCode;
  964. // this.donlineDlg(spuCode)
  965. },
  966. //商品下线原因 确定
  967. async donlineDlg() {
  968. await this.$refs.donline_Form.validate(async valid => {
  969. if (valid) {
  970. this.dialogFormVisible = false;
  971. this.get_donline(this.donline_form.spuCode);
  972. } else {
  973. console.log("error submit!!");
  974. return false;
  975. }
  976. });
  977. },
  978. async get_donline(spuCode) {
  979. await this.$confirm(`本次操作会下线本条SKU下的所有商品`, "提示", {
  980. // cancelButtonClass:"lzx_BtnErr",
  981. confirmButtonText: "确定",
  982. cancelButtonText: "取消",
  983. type: "warning",
  984. center: true
  985. })
  986. .then(async () => {
  987. this.loading = true;
  988. const model = this.donline_form;
  989. const res = await asyncRequest.goodupoffline(model);
  990. if (res && res.code === 0) {
  991. this.loading = false;
  992. this.$notify.success({
  993. title: res.message,
  994. message: ""
  995. });
  996. await this.searchList();
  997. } else if (res && res.code >= 100 && res.code <= 104) {
  998. await this.logout();
  999. } else {
  1000. this.loading = false;
  1001. this.$message.warning(res.message);
  1002. }
  1003. })
  1004. .catch(async () => {
  1005. console.log("取消");
  1006. });
  1007. }
  1008. }
  1009. };
  1010. </script>
  1011. <style lang="scss" scoped></style>