index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <template>
  2. <div>
  3. <basic-container>
  4. <el-row>
  5. <el-col :span="4">
  6. <avue-tree
  7. ref="treeRef"
  8. :option="treeOption"
  9. :data="treeData"
  10. @node-click="nodeClick"
  11. style="height: 73vh"
  12. @save="corpTypeVisible = true"
  13. >
  14. </avue-tree>
  15. </el-col>
  16. <el-col :span="20">
  17. <avue-crud
  18. :option="option"
  19. :search.sync="search"
  20. v-model="form"
  21. :table-loading="loading"
  22. :data="dataList"
  23. ref="crud"
  24. :key="key"
  25. @on-load="onLoad"
  26. @selection-change="selectionChange"
  27. :before-open="beforeOpen"
  28. @row-update="rowUpdate"
  29. @search-change="searchChange"
  30. @search-reset="resetChange"
  31. @refresh-change="refreshChange"
  32. @row-del="rowDel"
  33. :page.sync="page"
  34. >
  35. <template slot="filesListForm">
  36. <span style="font-size: 12px">(图片文件像素推荐700X700,有且只允许有一张主图,其余均为副图)</span>
  37. <c-upload
  38. :data="form.filesList"
  39. display
  40. basic
  41. deleteUrl="/api/gubersail-admin/productLaunchFiles/remove"
  42. :enumerationValue="160"
  43. />
  44. </template>
  45. <template slot="detailsTextForm">
  46. <avue-ueditor v-model="form.detailsText" :options="optionsUeditor"> </avue-ueditor>
  47. </template>
  48. <template slot-scope="{ row, index }" slot="priceOne">
  49. <el-input-number
  50. v-if="row.upAndDownShelves == 0"
  51. v-model="row.priceOne"
  52. label="请输入售价"
  53. :controls="false"
  54. :precision="2"
  55. size="small"
  56. style="width: 100%"
  57. ></el-input-number>
  58. <span v-if="row.upAndDownShelves == 1">{{ row.priceOne }}</span>
  59. </template>
  60. <template slot-scope="{ row, index }" slot="priceTwo">
  61. <el-input-number
  62. v-if="row.upAndDownShelves == 0"
  63. v-model="row.priceTwo"
  64. label="请输入售价"
  65. :controls="false"
  66. :precision="2"
  67. size="small"
  68. style="width: 100%"
  69. ></el-input-number>
  70. <span v-if="row.upAndDownShelves == 1">{{ row.priceTwo }}</span>
  71. </template>
  72. <template slot-scope="{ row, index }" slot="priceThree">
  73. <el-input-number
  74. v-if="row.upAndDownShelves == 0"
  75. v-model="row.priceThree"
  76. label="请输入售价"
  77. :controls="false"
  78. :precision="2"
  79. size="small"
  80. style="width: 100%"
  81. ></el-input-number>
  82. <span v-if="row.upAndDownShelves == 1">{{ row.priceThree }}</span>
  83. </template>
  84. <template slot-scope="{ row, index }" slot="priceFour">
  85. <el-input-number
  86. v-if="row.upAndDownShelves == 0"
  87. v-model="row.priceFour"
  88. label="请输入售价"
  89. :controls="false"
  90. :precision="2"
  91. size="small"
  92. style="width: 100%"
  93. ></el-input-number>
  94. <span v-if="row.upAndDownShelves == 1">{{ row.priceFour }}</span>
  95. </template>
  96. <template slot-scope="{ type, size, row, index }" slot="menu">
  97. <el-button
  98. :size="size"
  99. :type="type"
  100. :disabled="row.upAndDownShelves"
  101. @click="$refs.crud.rowEdit(row, index)"
  102. >编辑
  103. </el-button>
  104. <el-button
  105. :size="size"
  106. :type="type"
  107. :disabled="row.upAndDownShelves"
  108. @click="$refs.crud.rowDel(row, index)"
  109. >删除
  110. </el-button>
  111. <el-button :size="size" :type="type" :disabled="row.upAndDownShelves" @click="annexOpen(row, index)"
  112. >商城图片
  113. </el-button>
  114. <el-tooltip :content="`${row.upAndDownShelves == 0 ? '上架' : '下架'}`" placement="top">
  115. <el-switch
  116. style="margin-left: 10px"
  117. v-model="row.upAndDownShelves"
  118. @change="check(row)"
  119. :active-value="1"
  120. :inactive-value="0"
  121. >
  122. </el-switch>
  123. </el-tooltip>
  124. </template>
  125. <template slot-scope="{ type, size, row, $index }" slot="menuLeft">
  126. <el-button type="primary" size="mini" icon="el-icon-top" @click="outExport">导出</el-button>
  127. <el-button class="el-icon-bottom" type="warning" size="small" @click="excelBoxfun('名称')">
  128. 导入
  129. </el-button>
  130. <!-- <el-button class="el-icon-bottom" type="warning" size="small" @click="excelBoxfun('code')">
  131. 按编码导入
  132. </el-button> -->
  133. <el-button
  134. class="el-icon-document-copy"
  135. :disabled="selectionList.length === 0"
  136. type="primary"
  137. size="small"
  138. @click="change(row, 'up')"
  139. >批量上架
  140. </el-button>
  141. <el-button
  142. class="el-icon-document-copy"
  143. :disabled="selectionList.length === 0"
  144. type="danger"
  145. size="small"
  146. @click="change(row, 'down')"
  147. >批量下架
  148. </el-button>
  149. </template>
  150. </avue-crud>
  151. </el-col>
  152. </el-row>
  153. </basic-container>
  154. <el-dialog
  155. title="添加产品"
  156. v-if="excelBox"
  157. append-to-body
  158. :visible.sync="excelBox"
  159. :close-on-click-modal="false"
  160. width="555px"
  161. >
  162. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
  163. <template slot="excelTemplate">
  164. <el-button type="primary" @click="derivation">
  165. 点击下载<i class="el-icon-download el-icon--right"></i>
  166. </el-button>
  167. </template>
  168. </avue-form>
  169. <p style="text-align: center; color: #dc0505">温馨提示 第一次导入时请先下载模板</p>
  170. </el-dialog>
  171. <!--<el-dialog-->
  172. <!-- title="商城图片 (图片文件像素推荐700X700,有且只允许有一张主图,其余均为副图)"-->
  173. <!-- :visible.sync="enclosure"-->
  174. <!-- append-to-body-->
  175. <!-- width="70%">-->
  176. <!-- <c-upload :data="orderList" display basic deleteUrl="/api/gubersail-admin/productLaunchFiles/remove"-->
  177. <!-- :enumerationValue="160" />-->
  178. <!-- <span slot="footer" class="dialog-footer">-->
  179. <!-- <el-button @click="enclosure = false" size="small">取 消</el-button>-->
  180. <!-- <el-button type="primary" @click="saveAnnex" size="small">保 存</el-button>-->
  181. <!-- </span>-->
  182. <!--</el-dialog>-->
  183. <el-dialog
  184. title="附件上传"
  185. append-to-body
  186. :visible.sync="enclosure"
  187. width="555px"
  188. :close-on-click-modal="false"
  189. v-dialog-drag
  190. >
  191. <el-upload
  192. class="upload-demo"
  193. drag
  194. style="text-align: center"
  195. ref="upload"
  196. :action="action"
  197. :headers="headers"
  198. :on-success="onSuccess"
  199. :show-file-list="false"
  200. multiple
  201. >
  202. <i class="el-icon-upload"></i>
  203. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  204. <div class="el-upload__tip" slot="tip">如上传文件过大,请耐心等待上传成功</div>
  205. </el-upload>
  206. </el-dialog>
  207. </div>
  208. </template>
  209. <script>
  210. // @ts-nocheck
  211. import {
  212. getList,
  213. groundingList,
  214. submit,
  215. batchOperationProductLaunch,
  216. getDetail,
  217. remove,
  218. productLaunch,
  219. listAllP,
  220. } from "@/api/basicData/listingManagement/index.js";
  221. import { getToken } from "@/util/auth";
  222. import { getCorpTypes } from "@/api/basicData/commodityInformation";
  223. import { isProcurement } from "@/api/basicData/configuration";
  224. export default {
  225. name: "index",
  226. data() {
  227. return {
  228. query: {
  229. whether: 0,
  230. },
  231. action: "/api/blade-resource/oss/endpoint/put-file",
  232. headers: { "Blade-Auth": "Bearer " + getToken() },
  233. orderList: [],
  234. enclosure: false,
  235. dataId: 0,
  236. rowImg: [],
  237. data: [],
  238. sharedCompanyoptions: [],
  239. activeName: "searchList",
  240. dialogVisibles: false,
  241. selectedNodes: [], // 存储选择节点的数组
  242. tableData: [],
  243. //上架列表
  244. goodsListShow: [],
  245. // 商品列表暂存
  246. goodsListSave: [],
  247. goodsListPolicy: [],
  248. optionsUeditor: {
  249. //普通上传地址
  250. // action:'https://avuejs.com/imgupload',
  251. action: "/api/blade-resource/oss/endpoint/put-file",
  252. headers: { "Blade-Auth": "Bearer " + getToken() },
  253. props: {
  254. res: "data",
  255. url: "link",
  256. },
  257. },
  258. excelForm: {},
  259. excelOption: {
  260. submitBtn: false,
  261. emptyBtn: false,
  262. column: [
  263. {
  264. label: "模板下载",
  265. prop: "excelTemplate",
  266. formslot: true,
  267. span: 24,
  268. },
  269. {
  270. label: "模板上传",
  271. prop: "excelFile",
  272. type: "upload",
  273. drag: true,
  274. loadText: "模板上传中,请稍等",
  275. span: 24,
  276. propsHttp: {
  277. res: "data",
  278. },
  279. tip: "请上传 .xls,.xlsx 标准格式文件",
  280. action: "/api/gubersail-admin/productLaunch/import-productLaunch",
  281. },
  282. ],
  283. },
  284. templateUrl: "/api/gubersail-admin/productLaunch/export-productLaunch",
  285. treeOption: {
  286. addBtn: false,
  287. menu: false,
  288. size: "small",
  289. props: {
  290. labelText: "标题",
  291. label: "cname",
  292. value: "id",
  293. },
  294. },
  295. excelBox: false,
  296. corpTypeVisible: false,
  297. // 左侧搜索
  298. treeData: [],
  299. loading: false,
  300. search: {},
  301. form: {},
  302. dataList: [],
  303. selectionList: [],
  304. page: {
  305. pageSize: 20,
  306. currentPage: 1,
  307. total: 0,
  308. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
  309. },
  310. pageList: {
  311. pageSize: 10,
  312. currentPage: 1,
  313. total: 0,
  314. },
  315. key: 0,
  316. option: {
  317. viewBtn: false,
  318. editBtn: false,
  319. delBtn: false,
  320. addBtn: false,
  321. index: true,
  322. span: 8,
  323. border: true,
  324. selection: true,
  325. height: "auto",
  326. updateBtnText: "保存",
  327. searchMenuPosition: "right",
  328. align: "center",
  329. menuWidth: 220,
  330. searchSpan: 8,
  331. searchIcon: true,
  332. searchIndex: 2,
  333. highlightCurrentRow: true,
  334. dialogWidth: "90%",
  335. column: [
  336. {
  337. label: "商品名称",
  338. prop: "cname",
  339. search: true,
  340. disabled: true,
  341. overHidden: true,
  342. },
  343. {
  344. label: "规格型号",
  345. prop: "specificationAndModel",
  346. disabled: true,
  347. search: true,
  348. overHidden: true,
  349. },
  350. {
  351. label: "花纹",
  352. prop: "brandItem",
  353. disabled: true,
  354. search: true, // 是否搜索
  355. // type: 'select',
  356. // remote:true, // 是否为远程搜索
  357. // dicUrl:'/api/gubersail-admin/productLaunch/list?brandItem={{key}}', //key为当前输入值
  358. overHidden: true,
  359. },
  360. {
  361. label: "公司",
  362. prop: "salesCompanyName",
  363. disabled: true,
  364. overHidden: true,
  365. type: "select",
  366. props: {
  367. label: "fullName",
  368. value: "id",
  369. },
  370. dicUrl: "/api/blade-system/dept/top-list",
  371. },
  372. {
  373. label: "库存",
  374. prop: "inventory",
  375. disabled: true,
  376. overHidden: true,
  377. },
  378. {
  379. label: "产品状态",
  380. prop: "upAndDownShelves",
  381. filterable: true,
  382. display: false,
  383. search: true,
  384. hide: true,
  385. disabled: true,
  386. showColumn: false,
  387. type: "select",
  388. dicData: [
  389. {
  390. label: "上架",
  391. value: 1,
  392. },
  393. {
  394. label: "下架",
  395. value: 0,
  396. },
  397. ],
  398. },
  399. {
  400. label: "品牌",
  401. prop: "brandId",
  402. search: true,
  403. type: "select",
  404. props: {
  405. label: "cname",
  406. value: "id",
  407. },
  408. dicUrl: "/api/gubersail-admin/brandDesc/listAll?type=PP&enableOrNot=1",
  409. hide: true,
  410. filterable: true,
  411. disabled: true,
  412. overHidden: false,
  413. },
  414. {
  415. label: "品牌",
  416. prop: "brandName",
  417. disabled: true,
  418. overHidden: false,
  419. },
  420. {
  421. label: "售价1",
  422. prop: "priceOne",
  423. hide: false,
  424. overHidden: true,
  425. },
  426. {
  427. label: "售价2",
  428. prop: "priceTwo",
  429. hide: false,
  430. overHidden: true,
  431. },
  432. {
  433. label: "售价3",
  434. prop: "priceThree",
  435. hide: false,
  436. overHidden: true,
  437. },
  438. {
  439. label: "售价4",
  440. prop: "priceFour",
  441. hide: false,
  442. overHidden: true,
  443. },
  444. {
  445. label: "建议零售价",
  446. prop: "suggestedRetailPrice",
  447. hide: false,
  448. overHidden: true,
  449. },
  450. {
  451. label: "商品图片",
  452. prop: "filesList",
  453. hide: true,
  454. showColumn: false,
  455. overHidden: true,
  456. span: 24,
  457. },
  458. {
  459. label: "防爆",
  460. prop: "explosionProof",
  461. display: false,
  462. search: true,
  463. hide: false,
  464. showColumn: true,
  465. span: 8,
  466. type: "select",
  467. dicData: [
  468. {
  469. label: "否",
  470. value: 0,
  471. },
  472. {
  473. label: "是",
  474. value: 1,
  475. },
  476. ],
  477. },
  478. {
  479. label: "静音棉",
  480. prop: "originalFactory",
  481. display: false,
  482. search: true,
  483. hide: false,
  484. showColumn: true,
  485. span: 8,
  486. type: "select",
  487. dicData: [
  488. {
  489. label: "否",
  490. value: "0",
  491. },
  492. {
  493. label: "是",
  494. value: "1",
  495. },
  496. ],
  497. },
  498. {
  499. label: "自修补",
  500. prop: "selfRecovery",
  501. display: false,
  502. search: true,
  503. hide: false,
  504. showColumn: true,
  505. span: 8,
  506. type: "select",
  507. dicData: [
  508. {
  509. label: "否",
  510. value: "0",
  511. },
  512. {
  513. label: "是",
  514. value: "1",
  515. },
  516. ],
  517. },
  518. {
  519. label: "商品详情",
  520. prop: "detailsText",
  521. hide: true,
  522. span: 24,
  523. showColumn: false,
  524. overHidden: true,
  525. },
  526. ],
  527. },
  528. };
  529. },
  530. activated() {
  531. // getCorpTypes().then(res=>{
  532. // this.treeData = res.data.data
  533. // })
  534. listAllP({ whetherIntegral: "0" }).then((res) => {
  535. this.treeData = res.data.data;
  536. });
  537. this.onLoad(this.page, this.search);
  538. },
  539. async created() {
  540. this.key++;
  541. let i = 0;
  542. this.option.column.forEach((item) => {
  543. if (item.search) i++;
  544. });
  545. if (i % 3 !== 0) {
  546. const num = 3 - Number(i % 3);
  547. this.option.searchMenuSpan = num * 8;
  548. this.option.searchMenuPosition = "right";
  549. }
  550. },
  551. methods: {
  552. // 导入
  553. excelBoxfun(name) {
  554. if (name == "名称") {
  555. this.findObject(this.excelOption.column, "excelFile").action =
  556. "/api/gubersail-admin/tireStockDesc/importTireStockDesc";
  557. this.templateUrl = "/api/gubersail-admin/tireStockDesc/export-productLaunch";
  558. }
  559. this.excelBox = true;
  560. },
  561. // 导出
  562. outExport() {
  563. let config = { params: { ...this.search, whetherIntegral: 0 } };
  564. if (config.params) {
  565. for (const propName of Object.keys(config.params)) {
  566. const value = config.params[propName];
  567. if (value !== null && typeof value !== "undefined") {
  568. if (value instanceof Array) {
  569. for (const key of Object.keys(value)) {
  570. let params = propName + "[" + key + "]";
  571. config.params[params] = value[key];
  572. }
  573. delete config.params[propName];
  574. }
  575. }
  576. }
  577. }
  578. const routeData = this.$router.resolve({
  579. path: "/api/gubersail-admin/tireStockDesc/stockExport", //跳转目标窗口的地址
  580. query: {
  581. ...config.params, //括号内是要传递给新窗口的参数
  582. identification: this.url,
  583. },
  584. });
  585. window.open(routeData.href.slice(1, routeData.href.length) + "&" + `${this.website.tokenHeader}=${getToken()}`);
  586. },
  587. // 商城图片上传
  588. onSuccess(response, file, fileList) {
  589. let version = "2";
  590. if (this.form.filesList.length == 0) {
  591. version = "0";
  592. }
  593. this.form.filesList.push({
  594. fileName: response.data.originalName,
  595. url: response.data.link,
  596. sort: this.form.filesList.length,
  597. version: version,
  598. });
  599. submit({
  600. ...this.form,
  601. }).then((res) => {
  602. this.$message.success("修改成功");
  603. this.enclosure = false;
  604. this.onLoad(this.page, this.search);
  605. });
  606. },
  607. selectFocusfun(row) {
  608. console.log(row, 503);
  609. console.log(this.$refs.cruds, 504);
  610. },
  611. selectChangefun(value, row) {
  612. console.log(value, 506);
  613. if (value && Number(value) > 0) {
  614. this.$refs.cruds.toggleRowSelection(row, true);
  615. } else {
  616. this.$refs.cruds.toggleRowSelection(row, false);
  617. }
  618. },
  619. //打开附件
  620. annexOpen(row, index) {
  621. this.dataId = index;
  622. this.rowImg = row;
  623. this.orderList = row.filesList ? row.filesList : [];
  624. for (let order of this.orderList) {
  625. order.paymentType = order.typeFiles;
  626. }
  627. getDetail({ id: row.id }).then((res) => {
  628. this.form = res.data.data;
  629. });
  630. this.enclosure = true;
  631. },
  632. // 附件保存
  633. saveAnnex() {
  634. if (this.orderList.length > 0) {
  635. // 循环把编辑状态变成保存状态
  636. this.orderList.map((item) => {
  637. if (item.$cellEdit == true) {
  638. item.$cellEdit = false;
  639. } else {
  640. item.$cellEdit = true;
  641. }
  642. });
  643. let flag = this.orderList.some((item) => {
  644. return item.$version == "主图";
  645. });
  646. if (!flag) {
  647. this.$message.warning("请选择主图");
  648. return;
  649. }
  650. }
  651. this.rowImg.filesList = this.orderList;
  652. submit({
  653. ...this.rowImg,
  654. }).then((res) => {
  655. this.$message.success("添加成功");
  656. this.onLoad(this.page, this.search);
  657. });
  658. this.enclosure = false;
  659. },
  660. derivation() {
  661. window.open(`${this.templateUrl}?${this.website.tokenHeader}=${getToken()}`);
  662. },
  663. uploadAfter(res, done, loading, column) {
  664. this.excelBox = false;
  665. done();
  666. },
  667. nodeClick(data) {
  668. this.search.brandId = data.id;
  669. this.page.currentPage = 1;
  670. this.onLoad(this.page, this.search);
  671. },
  672. //刷新
  673. refreshChange() {
  674. this.onLoad(this.page, this.search);
  675. },
  676. //刷新触发
  677. refreshChangeCost() {
  678. // this.treeDeptId = ''
  679. this.page.currentPage = 1;
  680. this.onLoad(this.page);
  681. },
  682. searchChange(params, done) {
  683. // sharedCompanyList
  684. // this.search.sharedCompanyList = params.sharedCompany;
  685. // Vue.delete(params, 'sharedCompany');
  686. // Vue.delete(this.search, 'sharedCompany');
  687. this.page.currentPage = 1;
  688. this.onLoad(this.page, params);
  689. done();
  690. },
  691. selectionChange(list) {
  692. this.selectionList = list;
  693. },
  694. selectionChangeCost(list) {
  695. // this.goodsListSave = list
  696. this.tableData = list;
  697. },
  698. //新增
  699. commoditySelection() {
  700. delete this.page.brandId;
  701. this.goodsListShow = [];
  702. this.dialogVisibles = !this.dialogVisibles;
  703. this.tableData = [];
  704. this.goodsListSave = [];
  705. },
  706. //打开表单前
  707. beforeOpen(done, type) {
  708. // 查看和编辑逻辑
  709. if (["view", "edit"].includes(type)) {
  710. getDetail({ id: this.form.id }).then((res) => {
  711. this.form = res.data.data;
  712. done();
  713. });
  714. }
  715. },
  716. // 标签页切换
  717. tabHandle(data) {
  718. if (data.name == "searchList") {
  719. this.goodsListShow = this.data;
  720. this.page.total = this.pageList.total;
  721. } else if (data.name == "importStaging") {
  722. this.goodsListShow = this.goodsListSave;
  723. this.page.total = 0;
  724. }
  725. },
  726. removeStagList(row, index, type) {
  727. if (type === "policy") {
  728. this.goodsListPolicy.splice(row.$index, 1);
  729. if (this.goodsListPolicy.length == 0) {
  730. this.customerBuyFree.selection = true;
  731. this.optionPolicy.selection = true;
  732. this.$set(this.customerBuyFree, "menu", true);
  733. }
  734. } else if (type === "policy_buyAndGive") {
  735. this.buyAndGiveList.splice(row.$index, 1);
  736. if (this.buyAndGiveList.length == 0) {
  737. this.customerBuyFree.selection = true;
  738. this.optionPolicy.selection = true;
  739. this.$set(this.optionPolicy, "menu", true);
  740. }
  741. } else {
  742. console.log(row);
  743. this.goodsListSave.splice(row.$index, 1);
  744. }
  745. },
  746. rowDel(row, index) {
  747. this.$confirm("此操作将永久删除该行, 是否继续?", "提示", {
  748. confirmButtonText: "确定",
  749. cancelButtonText: "取消",
  750. type: "warning",
  751. }).then(() => {
  752. remove(row.id).then((res) => {
  753. this.$message({
  754. type: "success",
  755. message: "删除成功!",
  756. });
  757. this.dataList.splice(index, 1);
  758. this.onLoad(this.page);
  759. });
  760. });
  761. },
  762. //编辑确定
  763. rowUpdate(form, index, done, loading) {
  764. if (this.form.filesList.length > 0) {
  765. let flag = this.form.filesList.some((item) => {
  766. return item.$version == "主图";
  767. });
  768. if (!flag) {
  769. this.$message.warning("请选择主图");
  770. // done()
  771. loading();
  772. return;
  773. }
  774. // 循环把编辑状态变成保存状态
  775. this.form.filesList.map((item) => {
  776. if (item.$cellEdit == true) {
  777. // this.$set(item, "$cellEdit", false);
  778. item.$cellEdit = false;
  779. } else {
  780. // this.$set(item, "$cellEdit", true);
  781. item.$cellEdit = true;
  782. }
  783. });
  784. }
  785. console.log({ ...this.form }.detailsText, 651);
  786. submit({
  787. ...this.form,
  788. })
  789. .then((res) => {
  790. this.$message.success("修改成功");
  791. this.onLoad(this.page, this.search);
  792. done();
  793. })
  794. .catch((err) => {
  795. loading();
  796. });
  797. },
  798. resetChange() {
  799. if (document.getElementsByClassName("is-current")[0]) {
  800. let selected = document.getElementsByClassName("is-current")[0];
  801. selected.classList.remove("is-current");
  802. }
  803. },
  804. goodsresetChange() {
  805. this.query = this.$options.data().query;
  806. },
  807. check(row) {
  808. console.log(row.upAndDownShelves);
  809. if (row.upAndDownShelves == 1) {
  810. if (row.priceOne == 0 || row.priceTwo == 0) {
  811. row.upAndDownShelves = 0;
  812. return this.$message.error("请维护所有售价");
  813. }
  814. this.loading = true;
  815. productLaunch([row])
  816. .then((res) => {
  817. batchOperationProductLaunch({
  818. flag: row.upAndDownShelves,
  819. ids: row.id,
  820. })
  821. .then((res) => {
  822. this.onLoad(this.page, this.search);
  823. })
  824. .catch(() => {
  825. this.loading = false;
  826. });
  827. })
  828. .catch(() => {
  829. this.loading = false;
  830. });
  831. } else {
  832. this.loading = true;
  833. batchOperationProductLaunch({
  834. flag: row.upAndDownShelves,
  835. ids: row.id,
  836. })
  837. .then((res) => {
  838. this.onLoad(this.page, this.search);
  839. })
  840. .catch(() => {
  841. this.loading = false;
  842. });
  843. }
  844. },
  845. // 确认导入
  846. importGoods() {
  847. if (!this.goodsListSave.length) {
  848. this.$message.error("请选择");
  849. }
  850. if (
  851. this.goodsListSave.some(
  852. (item) =>
  853. item.priceOne == undefined ||
  854. item.priceTwo == undefined ||
  855. item.priceThree == undefined ||
  856. item.priceFour == undefined
  857. )
  858. ) {
  859. this.$message.error("请填写所有售价");
  860. } else {
  861. if (this.goodsListSave.length > 0) {
  862. this.goodsListSaveHandle();
  863. }
  864. }
  865. },
  866. goodsListSaveHandle() {
  867. this.goodsListSave.forEach((item) => {
  868. // item.sharedCompany ? item.sharedCompany.join(',') : ''
  869. item.sharedCompany = item.sharedCompany ? item.sharedCompany.toString() : "";
  870. this.goodsListSave.specificationAndModel = item.typeno;
  871. delete this.goodsListSave.typeno;
  872. // item.sharedCompany = JSON.stringify(item.sharedCompany)
  873. });
  874. productLaunch(this.goodsListSave).then((res) => {
  875. this.dialogVisibles = !this.dialogVisibles;
  876. this.onLoad(this.page, this.search);
  877. });
  878. },
  879. //导入商品触发
  880. importChoice() {
  881. // this.contactsData = this.contactsData.concat(this.tableData)
  882. if (this.tableData.length === 1) {
  883. this.goodsShowData[this.choiceIndexT].cname = this.tableData[0].cname;
  884. this.goodsShowData[this.choiceIndexT].code = this.tableData[0].code;
  885. this.goodsShowData[this.choiceIndexT].typeno = this.tableData[0].typeno;
  886. this.goodsShowData[this.choiceIndexT].itemType = this.tableData[0].typeno;
  887. this.goodsShowData[this.choiceIndexT].itemId = this.tableData[0].id;
  888. this.goodsShowData[this.choiceIndexT].priceCategory = this.tableData[0].goodsTypeName;
  889. this.goodsShowData[this.choiceIndexT].integralMultiples = this.tableData[0].integralMultiples;
  890. this.goodsShowData[this.choiceIndexT].corpId = this.tableData[0].corpId;
  891. this.goodsShowData[this.choiceIndexT].corpName = this.tableData[0].corpName;
  892. this.quantityChange(this.goodsShowData[this.choiceIndexT]);
  893. selectGoodsNum({
  894. goodsId: this.tableData[0].id,
  895. itemType: this.tableData[0].typeno,
  896. tradeType: "GN",
  897. warehouseId: this.form.storageId,
  898. }).then((res) => {
  899. if (res.data.data.length > 0) {
  900. this.goodsShowData[this.choiceIndexT].storageQuantityList = res.data.data;
  901. this.goodsShowData[this.choiceIndexT].storageId = res.data.data[0].storageId;
  902. this.goodsShowData[this.choiceIndexT].storageName = res.data.data[0].storageName;
  903. this.goodsShowData[this.choiceIndexT].storageQuantity = res.data.data[0].surplusRouteQuantity;
  904. if (res.data.data[0].tenantId !== "681169") {
  905. this.goodsShowData[this.choiceIndexT].purchaseAmount = res.data.data[0].stockPrice;
  906. }
  907. }
  908. });
  909. }
  910. this.dialogVisible = !this.dialogVisible;
  911. this.commodityData = false;
  912. },
  913. importStagList(row, index, type) {
  914. if (type === "policy") {
  915. this.goodsListPolicy.push(row);
  916. if (this.goodsListPolicy.length > 0) {
  917. this.customerBuyFree.selection = false;
  918. this.optionPolicy.selection = true;
  919. this.$set(this.customerBuyFree, "menu", false);
  920. }
  921. } else if (type === "policy_buyAndGive") {
  922. this.buyAndGiveList.push(row);
  923. if (this.buyAndGiveList.length > 0) {
  924. this.customerBuyFree.selection = true;
  925. this.optionPolicy.selection = false;
  926. this.$set(this.optionPolicy, "menu", false);
  927. }
  928. } else {
  929. this.goodsListSave.push(row);
  930. }
  931. },
  932. change(row, type) {
  933. let data = [];
  934. for (let item of this.selectionList) {
  935. data.push(item.id);
  936. }
  937. if (type === "up") {
  938. for (let item of this.selectionList) {
  939. if (item.priceOne == 0 || item.priceTwo == 0) {
  940. return this.$message.error("请维护所有售价");
  941. }
  942. }
  943. this.$confirm("是否确认全部上架?", "提示", {
  944. confirmButtonText: "确定",
  945. cancelButtonText: "取消",
  946. type: "warning",
  947. }).then(() => {
  948. batchOperationProductLaunch({
  949. flag: 1,
  950. ids: data.join(","),
  951. }).then((res) => {
  952. this.onLoad(this.page, this.search);
  953. });
  954. });
  955. } else if (type === "down") {
  956. this.$confirm("是否确认全部下架?", "提示", {
  957. confirmButtonText: "确定",
  958. cancelButtonText: "取消",
  959. type: "warning",
  960. }).then(() => {
  961. batchOperationProductLaunch({
  962. flag: 0,
  963. ids: data.join(","),
  964. }).then((res) => {
  965. this.onLoad(this.page, this.search);
  966. });
  967. });
  968. }
  969. },
  970. //新增搜索
  971. goodsSearchCost(params, done) {
  972. this.treeDeptId = "";
  973. params = {
  974. ...params,
  975. // artsVision: this.form.belongToCorpId
  976. };
  977. this.onLoad(this.page, params);
  978. done();
  979. },
  980. onLoad(page, params = {}) {
  981. // 深拷贝一份防止弹出框的搜索参数和外面表格的搜索参数一样
  982. let search = JSON.parse(JSON.stringify(this.search));
  983. search.cname = params.cname;
  984. // this.search.cname = params.cname
  985. // params.sharedCompany = params.$sharedCompany
  986. params = {
  987. ...params,
  988. current: page.currentPage,
  989. size: page.pageSize,
  990. ...Object.assign(params, search),
  991. // ...Object.assign(params, this.search),
  992. // billType: 0,
  993. whetherIntegral: "0",
  994. };
  995. this.loading = true;
  996. getList(params)
  997. .then((res) => {
  998. this.dataList = res.data.data.records;
  999. this.page.total = res.data.data.total;
  1000. this.pageList.total = res.data.data.total;
  1001. this.$nextTick(() => {
  1002. this.$refs.crud.doLayout();
  1003. });
  1004. this.loading = false;
  1005. })
  1006. .finally(() => {
  1007. this.loading = false;
  1008. });
  1009. },
  1010. //点击可用库存打开
  1011. storeInventoryOpen(row) {
  1012. this.$router.push({
  1013. path: "/tirePartsMall/basicData/listingManagement/detail",
  1014. query: {
  1015. goodsId: row.goodsId,
  1016. dot: row.dot,
  1017. },
  1018. });
  1019. },
  1020. },
  1021. };
  1022. </script>
  1023. <style scoped></style>