index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. <template>
  2. <div>
  3. <basic-container>
  4. <el-row>
  5. <el-col :span="4">
  6. <avue-tree ref="treeRef" :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;"
  7. @save="corpTypeVisible = true">
  8. </avue-tree>
  9. </el-col>
  10. <el-col :span="20">
  11. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  12. ref="crud" :key="key" @on-load="onLoad" @selection-change="selectionChange" :before-open="beforeOpen"
  13. @row-update="rowUpdate" @search-change="searchChange" @search-reset="resetChange"
  14. @refresh-change="refreshChange" @row-del="rowDel"
  15. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 273)"
  16. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 273)" :page.sync="page">
  17. <template slot="filesListForm">
  18. <span style="font-size: 12px;">(图片文件像素推荐700X750,有且只允许有一张主图,其余均为副图)</span>
  19. <c-upload :data="form.filesList" display basic deleteUrl="/api/blade-sales-part/productLaunchFiles/remove"
  20. :enumerationValue="160" />
  21. </template>
  22. <template slot="detailsTextForm">
  23. <avue-ueditor v-model="form.detailsText" :options="optionsUeditor"></avue-ueditor>
  24. </template>
  25. <template slot-scope="{type,size,row,index}" slot="menu">
  26. <el-button :size="size" :type="type" :disabled="row.upAndDownShelves"
  27. @click="$refs.crud.rowEdit(row, index)">编辑
  28. </el-button>
  29. <el-button :size="size" :type="type" :disabled="row.upAndDownShelves"
  30. @click="$refs.crud.rowDel(row, index)">删除
  31. </el-button>
  32. <el-tooltip :content="`${row.upAndDownShelves == 0 ? '上架' : '下架'}`" placement="top">
  33. <el-switch style="margin-left: 10px" v-model="row.upAndDownShelves" @change="check(row)" :active-value="1"
  34. :inactive-value="0">
  35. </el-switch>
  36. </el-tooltip>
  37. </template>
  38. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  39. <el-button type="primary" icon="el-icon-plus" size="small" @click="commoditySelection">选择产品
  40. </el-button>
  41. <el-button class="el-icon-bottom" type="warning" size="small" @click="excelBox = true">
  42. 导入
  43. </el-button>
  44. <el-button class="el-icon-document-copy" :disabled="selectionList.length === 0" type="primary" size="small"
  45. @click="change(row, 'up')">批量上架
  46. </el-button>
  47. <el-button class="el-icon-document-copy" :disabled="selectionList.length === 0" type="danger" size="small"
  48. @click="change(row, 'down')">批量下架
  49. </el-button>
  50. </template>
  51. </avue-crud>
  52. </el-col>
  53. </el-row>
  54. </basic-container>
  55. <el-dialog title="选择产品" v-if="dialogVisibles" append-to-body class="el-dialogDeep" :visible.async="dialogVisibles" width="80%"
  56. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" @close="dialogVisibles = false">
  57. <el-row :style="{ height: rowHeight }">
  58. <el-col :span="5" style="height: 100%;overflow-y: auto">
  59. <div>
  60. <el-scrollbar>
  61. <basic-container>
  62. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
  63. </basic-container>
  64. </el-scrollbar>
  65. </div>
  66. </el-col>
  67. <el-col :span="19">
  68. <!-- <basic-container> -->
  69. <avue-crud :option="optionTwo" :table-loading="loading" :data="goodsListShow" ref="cruds"
  70. @refresh-change="refreshChangeCost" @selection-change="selectionChangeCost" @search-change="goodsSearchCost"
  71. :page.sync="pages" @on-load="onLoad" @saveColumn="saveGoodsColumn"
  72. @resetColumn="resetGoodsColumn">
  73. <template slot="menuLeft">
  74. <el-tabs v-model="activeName" @tab-click="tabHandle">
  75. <el-tab-pane label="查询结果" name="searchList" />
  76. <el-tab-pane label="已选定数据" name="importStaging" />
  77. </el-tabs>
  78. </template>
  79. <template slot="priceOne" slot-scope="{row}">
  80. <el-input v-model="row.priceOne" size="small" :controls="false" :precision="0"
  81. style="width: 100%" />
  82. </template>
  83. <template slot="priceTwo" slot-scope="{ row }">
  84. <el-input v-model="row.priceTwo" size="small"></el-input>
  85. <!-- <span v-else>{{ row.refreshChange | IntegerFormat }}</span> -->
  86. </template>
  87. <!--花纹-->
  88. <template slot-scope="{row}" slot="brandItem">
  89. <!--<el-select-->
  90. <!-- v-model="row.brandItem"-->
  91. <!-- multiple-->
  92. <!-- filterable-->
  93. <!-- remote-->
  94. <!-- reserve-keyword-->
  95. <!-- placeholder="请输入关键词"-->
  96. <!-- :remote-method="remoteMethod"-->
  97. <!-- :loading="loading">-->
  98. <!-- <el-option-->
  99. <!-- v-for="item in goodsListShow"-->
  100. <!-- :key="item.value"-->
  101. <!-- :label="item.brandItem"-->
  102. <!-- :value="item.value">-->
  103. <!-- </el-option>-->
  104. <!--</el-select>-->
  105. </template>
  106. <template slot="priceThree" slot-scope="{ row }">
  107. <el-input v-model="row.priceThree" size="small"></el-input>
  108. <!-- <span v-else>{{ row.refreshChange | IntegerFormat }}</span> -->
  109. </template>
  110. <template slot="priceFour" slot-scope="{ row }">
  111. <el-input v-model="row.priceFour" size="small"></el-input>
  112. <!-- <span v-else>{{ row.refreshChange | IntegerFormat }}</span> -->
  113. </template>
  114. <template slot="sharedCompany" slot-scope="{ row, index }">
  115. <span style="display:flex">
  116. <el-select v-model="row.sharedCompany" multiple placeholder="请选择" size="small" filterable
  117. style="width:60%">
  118. <el-option v-for="item in sharedCompanyoptions" :key="item.id" :label="item.fullName"
  119. :value="item.id">
  120. </el-option>
  121. </el-select>
  122. </span>
  123. </template>
  124. <template slot-scope="scope" slot="menu">
  125. <el-button type="text" icon="el-icon-edit" size="small"
  126. @click.stop="importStagList(scope.row, scope.index)" v-if="activeName == 'searchList'"
  127. :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1">选择
  128. </el-button>
  129. <el-button type="text" icon="el-icon-delete" size="small"
  130. @click.stop="removeStagList(scope.row, scope.index)" v-else>移除
  131. </el-button>
  132. </template>
  133. </avue-crud>
  134. <!-- </basic-container> -->
  135. </el-col>
  136. </el-row>
  137. <span slot="footer" class="dialog-footer">
  138. <el-button @click="dialogVisibles = false" :loading="saveLoading">取 消</el-button>
  139. <el-button type="primary" @click="importGoods" v-if="commodityData !== true" :loading="saveLoading">导入</el-button>
  140. <el-button type="primary" @click="importChoice" v-if="commodityData === true" :loading="saveLoading"
  141. :disabled="tableData.length !== 1">导入</el-button>
  142. </span>
  143. </el-dialog>
  144. <el-dialog title="添加产品" v-if="excelBox" append-to-body :visible.sync="excelBox" :close-on-click-modal="false" width="555px">
  145. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
  146. <template slot="excelTemplate">
  147. <el-button type="primary" @click="derivation">
  148. 点击下载<i class="el-icon-download el-icon--right"></i>
  149. </el-button>
  150. </template>
  151. </avue-form>
  152. <p style="text-align: center;color: #DC0505">
  153. 温馨提示 第一次导入时请先下载模板
  154. </p>
  155. </el-dialog>
  156. </div>
  157. </template>
  158. <script>
  159. import {
  160. getList,
  161. groundingList,
  162. submit,
  163. batchOperationProductLaunch,
  164. getDetail,
  165. remove,
  166. productLaunch,
  167. deptList, listAllP
  168. } from "@/api/tirePartsMall/basicData/listingManagement/index.js";
  169. import { getToken } from "@/util/auth";
  170. import commodity from "./commodity.json"
  171. export default {
  172. name: "index",
  173. data() {
  174. return {
  175. data: [],
  176. sharedCompanyoptions: [],
  177. activeName: 'searchList',
  178. dialogVisibles: false,
  179. selectedNodes: [],// 存储选择节点的数组
  180. tableData: [],
  181. //上架列表
  182. goodsListShow: [],
  183. // 商品列表暂存
  184. goodsListSave: [],
  185. goodsListPolicy: [],
  186. optionsUeditor: {
  187. //普通上传地址
  188. // action:'https://avuejs.com/imgupload',
  189. action: "/api/blade-resource/oss/endpoint/put-file",
  190. headers: { "Blade-Auth": "Bearer " + getToken() },
  191. props: {
  192. res: "data",
  193. url: 'link'
  194. }
  195. },
  196. optionTwo: commodity,
  197. excelForm: {},
  198. excelOption: {
  199. submitBtn: false,
  200. emptyBtn: false,
  201. column: [
  202. {
  203. label: "模板下载",
  204. prop: "excelTemplate",
  205. formslot: true,
  206. span: 24
  207. },
  208. {
  209. label: "模板上传",
  210. prop: "excelFile",
  211. type: "upload",
  212. drag: true,
  213. loadText: "模板上传中,请稍等",
  214. span: 24,
  215. propsHttp: {
  216. res: "data"
  217. },
  218. tip: "请上传 .xls,.xlsx 标准格式文件",
  219. action: "/api/blade-sales-part/productLaunch/import-productLaunch"
  220. }
  221. ]
  222. },
  223. treeOption: {
  224. addBtn: false,
  225. menu: false,
  226. size: "small",
  227. props: {
  228. labelText: "标题",
  229. label: "cname",
  230. value: "id",
  231. }
  232. },
  233. excelBox: false,
  234. corpTypeVisible: false,
  235. // 左侧搜索
  236. treeData: [],
  237. loading: false,
  238. search: {},
  239. form: {},
  240. dataList: [],
  241. selectionList: [],
  242. page: {
  243. pageSize: 20,
  244. currentPage: 1,
  245. total: 0,
  246. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  247. },
  248. pageList: {
  249. pageSize: 10,
  250. currentPage: 1,
  251. total: 0
  252. },
  253. key: 0,
  254. option: {},
  255. optionList: {
  256. viewBtn: false,
  257. editBtn: false,
  258. delBtn: false,
  259. addBtn: false,
  260. index: true,
  261. span: 8,
  262. border: true,
  263. selection: true,
  264. height: "auto",
  265. updateBtnText:'保存',
  266. searchMenuPosition: "right",
  267. align: "center",
  268. menuWidth: 150,
  269. searchSpan: 8,
  270. searchIcon: true,
  271. searchIndex: 2,
  272. highlightCurrentRow: true,
  273. dialogWidth: "90%",
  274. column: [{
  275. label: '轮胎名称',
  276. prop: 'cname',
  277. search: true,
  278. disabled: true,
  279. overHidden: true,
  280. }, {
  281. label: '规格型号',
  282. prop: 'specificationAndModel',
  283. disabled: true,
  284. search: true,
  285. overHidden: true,
  286. },{
  287. label: '花纹',
  288. prop: 'brandItem',
  289. disabled: true,
  290. search: true, // 是否搜索
  291. // type: 'select',
  292. // remote:true, // 是否为远程搜索
  293. // dicUrl:'/api/blade-sales-part/productLaunch/list?brandItem={{key}}', //key为当前输入值
  294. overHidden: true,
  295. }, {
  296. label: '公司',
  297. prop: 'salesCompanyName',
  298. disabled: true,
  299. overHidden: true,
  300. type: 'select',
  301. props: {
  302. label: 'fullName',
  303. value: 'id'
  304. },
  305. dicUrl: '/api/blade-system/dept/top-list'
  306. }, {
  307. label: '库存',
  308. prop: 'inventory',
  309. disabled: true,
  310. overHidden: true,
  311. }, {
  312. label: '产品状态',
  313. prop: 'upAndDownShelves',
  314. filterable: true,
  315. display: false,
  316. search: true,
  317. hide: true,
  318. disabled: true,
  319. showColumn: false,
  320. type: 'select',
  321. dicData: [{
  322. label: "上架",
  323. value: 1
  324. }, {
  325. label: "下架",
  326. value: 0
  327. }]
  328. }, {
  329. label: "品牌",
  330. prop: "brandName",
  331. disabled: true,
  332. overHidden: false,
  333. }, {
  334. label: "售价1",
  335. prop: "priceOne",
  336. hide: false,
  337. overHidden: true,
  338. }, {
  339. label: "售价2",
  340. prop: "priceTwo",
  341. hide: false,
  342. overHidden: true,
  343. }, {
  344. label: "售价3",
  345. prop: "priceThree",
  346. hide: false,
  347. overHidden: true,
  348. }, {
  349. label: "售价4",
  350. prop: "priceFour",
  351. hide: false,
  352. overHidden: true,
  353. },
  354. {
  355. label: "共享公司",
  356. prop: "sharedCompany",
  357. // searchProp: "sharedCompanyList",
  358. search: true,
  359. overHidden: true,
  360. // tags: true,
  361. multiple: true, //将可选变为多选
  362. searchMultiple:false,
  363. type: 'select',
  364. props: {
  365. label: 'fullName',
  366. value: 'id'
  367. },
  368. dicUrl: '/api/blade-system/dept/deptList'
  369. },
  370. {
  371. label: "轮胎图片",
  372. prop: "filesList",
  373. hide: true,
  374. showColumn: false,
  375. overHidden: true,
  376. span: 24,
  377. },{
  378. label: "防爆",
  379. prop: "explosionProof",
  380. search: true,
  381. span: 8,
  382. type: 'select',
  383. dicData: [{
  384. label: '否',
  385. value: 0
  386. }, {
  387. label: '是',
  388. value: 1
  389. }],
  390. }, {
  391. label: "原厂",
  392. prop: "originalFactory",
  393. search: true,
  394. span: 8,
  395. type: 'select',
  396. dicData: [{
  397. label: '否',
  398. value: "0"
  399. }, {
  400. label: '是',
  401. value: "1"
  402. }],
  403. },
  404. {
  405. label: "自修补",
  406. prop: "selfRecovery",
  407. search: true,
  408. span: 8,
  409. type: 'select',
  410. dicData: [{
  411. label: '否',
  412. value: "0"
  413. }, {
  414. label: '是',
  415. value: "1"
  416. }],
  417. }, {
  418. label: "轮胎详情",
  419. prop: "detailsText",
  420. hide: true,
  421. span: 24,
  422. showColumn: false,
  423. overHidden: true,
  424. }]
  425. }
  426. }
  427. },
  428. activated() {
  429. listAllP({type:'PP'}).then(res => {
  430. this.treeData = res.data.data
  431. })
  432. this.onLoad(this.page, this.search)
  433. },
  434. async created() {
  435. this.option = await this.getColumnData(this.getColumnName(273), this.optionList);
  436. this.optionTwo = await this.getColumnData(
  437. this.getColumnName(280),
  438. this.optionTwo
  439. );
  440. this.key++
  441. let i = 0;
  442. this.option.column.forEach(item => {
  443. if (item.search) i++
  444. })
  445. this.$refs.crud.dicInit()
  446. if (i % 3 !== 0) {
  447. const num = 3 - Number(i % 3)
  448. this.option.searchMenuSpan = num * 8;
  449. this.option.searchMenuPosition = "right";
  450. }
  451. },
  452. methods: {
  453. derivation() {
  454. window.open(
  455. `/api/blade-sales-part/productLaunch/export-productLaunch?${this.website.tokenHeader
  456. }=${getToken()}`
  457. );
  458. },
  459. uploadAfter(res, done, loading, column) {
  460. this.excelBox = false;
  461. this.refreshChange();
  462. done();
  463. },
  464. nodeClick(data) {
  465. this.search.brandId = data.id
  466. this.page.currentPage = 1;
  467. this.onLoad(this.page, this.search);
  468. },
  469. //刷新
  470. refreshChange() {
  471. this.onLoad(this.page, this.search)
  472. },
  473. //刷新触发
  474. refreshChangeCost() {
  475. // this.treeDeptId = ''
  476. this.page.currentPage = 1;
  477. this.onLoad(this.page);
  478. },
  479. searchChange(params, done) {
  480. // sharedCompanyList
  481. // this.search.sharedCompanyList = params.sharedCompany;
  482. // Vue.delete(params, 'sharedCompany');
  483. // Vue.delete(this.search, 'sharedCompany');
  484. this.onLoad(this.page, params)
  485. done();
  486. },
  487. selectionChange(list) {
  488. this.selectionList = list
  489. },
  490. selectionChangeCost(list) {
  491. this.goodsListSave = list
  492. this.tableData = list
  493. },
  494. //新增
  495. commoditySelection() {
  496. delete this.page.brandId
  497. this.goodsListShow = []
  498. this.dialogVisibles = !this.dialogVisibles
  499. this.tableData = []
  500. this.goodsListSave = [];
  501. },
  502. //打开表单前
  503. beforeOpen(done, type) {
  504. // 查看和编辑逻辑
  505. if (['view', 'edit'].includes(type)) {
  506. getDetail({ id: this.form.id }).then(res => {
  507. this.form = res.data.data
  508. done();
  509. })
  510. }
  511. },
  512. // 标签页切换
  513. tabHandle(data) {
  514. if (data.name == 'searchList') {
  515. this.goodsListShow = this.data;
  516. this.page.total = this.pageList.total
  517. } else if (data.name == 'importStaging') {
  518. this.goodsListShow = this.goodsListSave;
  519. this.page.total = 0
  520. }
  521. },
  522. removeStagList(row, index, type) {
  523. if (type === 'policy') {
  524. this.goodsListPolicy.splice(row.$index, 1)
  525. if (this.goodsListPolicy.length == 0) {
  526. this.customerBuyFree.selection = true
  527. this.optionPolicy.selection = true
  528. this.$set(this.customerBuyFree, 'menu', true)
  529. }
  530. } else if (type === 'policy_buyAndGive') {
  531. this.buyAndGiveList.splice(row.$index, 1)
  532. if (this.buyAndGiveList.length == 0) {
  533. this.customerBuyFree.selection = true
  534. this.optionPolicy.selection = true
  535. this.$set(this.optionPolicy, 'menu', true)
  536. }
  537. } else {
  538. this.goodsListSave.splice(row.$index, 1)
  539. }
  540. },
  541. rowDel(row, index) {
  542. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  543. confirmButtonText: '确定',
  544. cancelButtonText: '取消',
  545. type: 'warning'
  546. }).then(() => {
  547. remove(row.id).then((res) => {
  548. this.$message({
  549. type: 'success',
  550. message: '删除成功!'
  551. });
  552. this.dataList.splice(index, 1);
  553. this.onLoad(this.page)
  554. })
  555. })
  556. },
  557. //编辑确定
  558. rowUpdate(form, index, done, loading) {
  559. if (this.form.filesList.length > 0) {
  560. // 循环把编辑状态变成保存状态
  561. this.form.filesList.map((item)=>{
  562. if (item.$cellEdit == true) {
  563. // this.$set(item, "$cellEdit", false);
  564. item.$cellEdit = false
  565. } else {
  566. // this.$set(item, "$cellEdit", true);
  567. item.$cellEdit = true
  568. }
  569. })
  570. let flag = this.form.filesList.some(item => {
  571. return item.$version == '主图'
  572. })
  573. if (!flag) {
  574. this.$message.warning('请选择主图')
  575. done()
  576. return
  577. }
  578. }
  579. submit({
  580. ...this.form
  581. }).then(res => {
  582. this.$message.success("修改成功")
  583. this.onLoad(this.page, this.search)
  584. done()
  585. }).catch((err) => {
  586. loading()
  587. })
  588. // submit({
  589. // ...form
  590. // }).then(res => {
  591. // this.onLoad(this.page, this.search)
  592. // done()
  593. // }).catch(() => {
  594. // loading()
  595. // })
  596. },
  597. resetChange() {
  598. if(document.getElementsByClassName("is-current")[0]){
  599. let selected = document.getElementsByClassName("is-current")[0]
  600. selected.classList.remove("is-current")
  601. }
  602. },
  603. check(row) {
  604. batchOperationProductLaunch({
  605. flag: row.upAndDownShelves,
  606. ids: row.id
  607. }).then(res => {
  608. this.onLoad(this.page, this.search)
  609. })
  610. },
  611. // 确认导入
  612. importGoods() {
  613. if (!this.goodsListSave.length) {
  614. this.$message.error('请选择')
  615. }
  616. if (this.goodsListSave.some(item => item.priceOne == undefined || item.priceTwo == undefined || item.priceThree == undefined || item.priceFour == undefined)) {
  617. this.$message.error('请填写所有售价');
  618. } else {
  619. if (this.goodsListSave.length > 0) {
  620. this.goodsListSaveHandle()
  621. }
  622. }
  623. },
  624. goodsListSaveHandle() {
  625. this.goodsListSave.forEach(item => {
  626. // item.sharedCompany ? item.sharedCompany.join(',') : ''
  627. item.sharedCompany = item.sharedCompany?item.sharedCompany.toString():'';
  628. this.goodsListSave.specificationAndModel = item.typeno
  629. delete this.goodsListSave.typeno
  630. // item.sharedCompany = JSON.stringify(item.sharedCompany)
  631. })
  632. productLaunch(this.goodsListSave).then(res => {
  633. this.dialogVisibles = !this.dialogVisibles
  634. })
  635. },
  636. //导入商品触发
  637. importChoice() {
  638. return
  639. // this.contactsData = this.contactsData.concat(this.tableData)
  640. if (this.tableData.length === 1) {
  641. this.goodsShowData[this.choiceIndexT].cname = this.tableData[0].cname
  642. this.goodsShowData[this.choiceIndexT].code = this.tableData[0].code
  643. this.goodsShowData[this.choiceIndexT].typeno = this.tableData[0].typeno
  644. this.goodsShowData[this.choiceIndexT].itemType = this.tableData[0].typeno
  645. this.goodsShowData[this.choiceIndexT].itemId = this.tableData[0].id
  646. this.goodsShowData[this.choiceIndexT].priceCategory = this.tableData[0].goodsTypeName
  647. this.goodsShowData[this.choiceIndexT].integralMultiples = this.tableData[0].integralMultiples
  648. this.goodsShowData[this.choiceIndexT].corpId = this.tableData[0].corpId
  649. this.goodsShowData[this.choiceIndexT].corpName = this.tableData[0].corpName
  650. this.quantityChange(this.goodsShowData[this.choiceIndexT])
  651. selectGoodsNum({
  652. goodsId: this.tableData[0].id,
  653. itemType: this.tableData[0].typeno,
  654. tradeType: 'GN',
  655. warehouseId: this.form.storageId
  656. }).then(res => {
  657. if (res.data.data.length > 0) {
  658. this.goodsShowData[this.choiceIndexT].storageQuantityList = res.data.data
  659. this.goodsShowData[this.choiceIndexT].storageId = res.data.data[0].storageId
  660. this.goodsShowData[this.choiceIndexT].storageName = res.data.data[0].storageName
  661. this.goodsShowData[this.choiceIndexT].storageQuantity = res.data.data[0].surplusRouteQuantity
  662. if (res.data.data[0].tenantId !== "681169") {
  663. this.goodsShowData[this.choiceIndexT].purchaseAmount = res.data.data[0].stockPrice
  664. }
  665. }
  666. })
  667. }
  668. this.dialogVisible = !this.dialogVisible
  669. this.commodityData = false
  670. },
  671. importStagList(row, index, type) {
  672. if (type === 'policy') {
  673. this.goodsListPolicy.push(row);
  674. if (this.goodsListPolicy.length > 0) {
  675. this.customerBuyFree.selection = false
  676. this.optionPolicy.selection = true
  677. this.$set(this.customerBuyFree, 'menu', false)
  678. }
  679. } else if (type === 'policy_buyAndGive') {
  680. this.buyAndGiveList.push(row);
  681. if (this.buyAndGiveList.length > 0) {
  682. this.customerBuyFree.selection = true
  683. this.optionPolicy.selection = false
  684. this.$set(this.optionPolicy, 'menu', false)
  685. }
  686. } else {
  687. this.goodsListSave.push(row);
  688. }
  689. },
  690. change(row, type) {
  691. let data = []
  692. for (let item of this.selectionList) {
  693. data.push(item.id)
  694. }
  695. if (type === "up") {
  696. // for (let item of this.selectionList) {
  697. // if (!Number(item.salesPrice)) return this.$message.error("上架失败,商城价格不能为0")
  698. // }
  699. this.$confirm('是否确认全部上架?', '提示', {
  700. confirmButtonText: '确定',
  701. cancelButtonText: '取消',
  702. type: 'warning'
  703. }).then(() => {
  704. batchOperationProductLaunch({
  705. flag: 1,
  706. ids: data.join(",")
  707. }).then(res => {
  708. this.onLoad(this.page, this.search)
  709. })
  710. })
  711. } else if (type === "down") {
  712. this.$confirm('是否确认全部下架?', '提示', {
  713. confirmButtonText: '确定',
  714. cancelButtonText: '取消',
  715. type: 'warning'
  716. }).then(() => {
  717. batchOperationProductLaunch({
  718. flag: 0,
  719. ids: data.join(",")
  720. }).then(res => {
  721. this.onLoad(this.page, this.search)
  722. })
  723. })
  724. }
  725. },
  726. //新增搜索
  727. goodsSearchCost(params, done) {
  728. this.treeDeptId = ''
  729. params = {
  730. ...params,
  731. // artsVision: this.form.belongToCorpId
  732. }
  733. this.onLoad(this.page, params);
  734. done()
  735. },
  736. onLoad(page, params = {}) {
  737. // 深拷贝一份防止弹出框的搜索参数和外面表格的搜索参数一样
  738. let search = JSON.parse(JSON.stringify(this.search))
  739. search.cname = params.cname
  740. // this.search.cname = params.cname
  741. // params.sharedCompany = params.$sharedCompany
  742. params = {
  743. ...params,
  744. current: page.currentPage,
  745. size: page.pageSize,
  746. ...Object.assign(params, search),
  747. // ...Object.assign(params, this.search),
  748. billType: 0
  749. }
  750. this.loading = true
  751. getList(params).then(res => {
  752. this.dataList = res.data.data.records
  753. this.page.total = res.data.data.total
  754. this.pageList.total = res.data.data.total
  755. this.$nextTick(() => {
  756. this.$refs.crud.doLayout();
  757. });
  758. this.loading = false
  759. }).finally(() => {
  760. this.loading = false
  761. })
  762. this.loading = true
  763. groundingList(params).then(res => {
  764. this.goodsListShow = res.data.data.records
  765. this.data = res.data.data.records;
  766. this.pages.total = res.data.data.total
  767. this.loading = false
  768. }).finally(() => {
  769. this.loading = false
  770. })
  771. deptList().then(res => {
  772. this.sharedCompanyoptions = res.data.data
  773. })
  774. },
  775. async saveGoodsColumn() {
  776. const inSave = await this.saveColumnData(
  777. this.getColumnName(280),
  778. this.optionTwo
  779. );
  780. if (inSave) {
  781. this.$message.success("保存成功");
  782. //关闭窗口
  783. this.$refs.cruds.$refs.dialogColumn.columnBox = false;
  784. this.$nextTick(() => {
  785. this.$refs.cruds.doLayout()
  786. })
  787. }
  788. },
  789. async resetGoodsColumn() {
  790. this.optionTwo = commodity;
  791. const inSave = await this.delColumnData(
  792. this.getColumnName(280),
  793. commodity
  794. );
  795. if (inSave) {
  796. this.$nextTick(() => {
  797. this.$refs.cruds.doLayout()
  798. })
  799. this.$message.success("重置成功");
  800. //关闭窗口
  801. setTimeout(() => {
  802. this.$refs.cruds.$refs.dialogColumn.columnBox = false;
  803. }, 1000);
  804. }
  805. },
  806. //自定义列保存
  807. async saveColumnTwo(ref, option, optionBack, code) {
  808. /**
  809. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  810. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  811. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  812. */
  813. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  814. if (inSave) {
  815. this.$message.success("保存成功");
  816. //关闭窗口
  817. this.$nextTick(() => {
  818. this.$refs.crud.doLayout();
  819. });
  820. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  821. }
  822. },
  823. //自定义列重置
  824. async resetColumnTwo(ref, option, optionBack, code) {
  825. this[option] = this[optionBack];
  826. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  827. if (inSave) {
  828. this.$message.success("重置成功");
  829. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  830. this.$nextTick(() => {
  831. this.$refs.crud.doLayout();
  832. });
  833. }
  834. }
  835. }
  836. }
  837. </script>
  838. <style scoped></style>