detailsPageEdit.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <!-- <i class="back-icon el-icon-arrow-left"></i><i style="font-style:normal">返回管理列表</i>-->
  6. <el-button
  7. type="danger"
  8. style="border: none;background: none;color: red"
  9. icon="el-icon-arrow-left"
  10. @click="backToList"
  11. >返回列表
  12. </el-button>
  13. </div>
  14. <el-button
  15. style="margin-right: 110px"
  16. class="add-customer-btn"
  17. type="primary"
  18. :disabled="disabled"
  19. size="small"
  20. @click="editCustomer"
  21. >{{ form.id ? "确认修改" : "确认新增" }}
  22. </el-button>
  23. <el-dropdown class="add-customer-btn">
  24. <el-button type="primary" size="small">
  25. 审核处理<i class="el-icon-arrow-down el-icon--right"></i>
  26. </el-button>
  27. <el-dropdown-menu slot="dropdown">
  28. <el-dropdown-item @click.native="pleaseCheck" :disabled="form.auditStatus != 2">请核数据</el-dropdown-item>
  29. <el-dropdown-item @click.native="checkScheduleDialog = true,checkId=form.id" :disabled="form.auditStatus === 1 || form.auditStatus === 2">审核进度</el-dropdown-item>
  30. <!-- <el-dropdown-item>撤销请核</el-dropdown-item>-->
  31. <!-- <el-dropdown-item>审批数据</el-dropdown-item>-->
  32. </el-dropdown-menu>
  33. </el-dropdown>
  34. </div>
  35. <div style="margin-top: 60px">
  36. <el-form
  37. :model="form"
  38. ref="form"
  39. label-width="130px"
  40. class="demo-ruleForm"
  41. >
  42. <containerTitle title="基础资料"></containerTitle>
  43. <basic-container style="margin-bottom: 10px">
  44. <el-row>
  45. <el-col
  46. v-for="(item, index) in basicData.column"
  47. :key="index"
  48. :span="item.span ? item.span : 8"
  49. >
  50. <el-form-item
  51. :label="item.label"
  52. :prop="item.prop"
  53. :rules="item.rules"
  54. >
  55. <!-- <avue-input-tree v-if="item.prop === 'corpsTypeId'" leaf-only multiple :props="{label:'title'}"v-model="form[item.prop]" placeholder="请选择内容" type="tree" :dic="dic"/>-->
  56. <el-date-picker
  57. v-if="item.type === 'datetime'"
  58. style="width: 100%;"
  59. v-model="form[item.prop]"
  60. size="small"
  61. type="datetime"
  62. placeholder="选择日期"
  63. value-format="yyyy-MM-dd HH:mm:ss"
  64. />
  65. <span v-else-if="item.type === 'select'">
  66. <el-select
  67. v-model="form[item.prop]"
  68. slot="prepend"
  69. style="width: 100%;"
  70. size="small"
  71. placeholder="请选择"
  72. >
  73. <el-option
  74. v-for="(item, index) in item.dicData"
  75. :label="item.label"
  76. :value="item.value"
  77. :key="index"
  78. ></el-option>
  79. </el-select>
  80. </span>
  81. <crop-select
  82. v-else-if="item.prop === 'corps'"
  83. v-model="form[item.prop]"
  84. :collapseTags="true"
  85. :multiple="true"
  86. corpType="KH"
  87. style="width: 100%"
  88. @getCorpList="getCorpList"
  89. ></crop-select>
  90. <!-- <selectComponent v-else-if="item.prop === 'corps'" v-model="form[item.prop]"-->
  91. <!-- :configuration="configuration" style="width: 100%"/>-->
  92. <el-input
  93. type="textarea"
  94. v-else-if="item.type === 'textarea'"
  95. v-model="form[item.prop]"
  96. size="small"
  97. autocomplete="off"
  98. :disabled="item.disabled"
  99. ></el-input>
  100. <el-input
  101. type="age"
  102. v-else
  103. v-model="form[item.prop]"
  104. size="small"
  105. autocomplete="off"
  106. :disabled="item.disabled ? item.disabled : false"
  107. ></el-input>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. </basic-container>
  112. <containerTitle title="特价促销"></containerTitle>
  113. <basic-container style="margin-bottom: 10px">
  114. <avue-crud
  115. :table-loading="contactLoading"
  116. :page.sync="contactPage"
  117. :option="customerContact"
  118. v-model="contactsForm"
  119. :data="contactsData"
  120. ref="crudContact"
  121. @current-change="currentChange"
  122. @size-change="sizeChange"
  123. @row-save="rowSave"
  124. @row-click="handleRowClick"
  125. @row-update="rowUpdate"
  126. @row-del="rowDel"
  127. >
  128. <template slot="code" slot-scope="{ row, index }">
  129. <el-button
  130. size="small"
  131. type="text"
  132. @click="rePick(row, index, 1)"
  133. :disabled="disabled"
  134. class="picker"
  135. style="padding:4px 10px;float:left"
  136. >选择</el-button
  137. >
  138. <span> {{ row.code }}</span>
  139. </template>
  140. <template slot="corpId" slot-scope="{ row, index }">
  141. <crop-select
  142. v-if="row.$cellEdit"
  143. v-model="row.corpId"
  144. :cropIndex="index"
  145. corpType="GYS"
  146. @getCorpData="getcorpId"
  147. :disabled="detailData.seeDisabled"
  148. ></crop-select>
  149. <span v-else>{{ row.corpName }}</span>
  150. </template>
  151. <template slot="menuLeft">
  152. <el-button
  153. type="primary"
  154. icon="el-icon-plus"
  155. size="small"
  156. @click.stop="newSpecial"
  157. >新增明细</el-button
  158. >
  159. <el-button
  160. type="primary"
  161. size="small"
  162. icon="el-icon-download"
  163. @click="downloadHandle"
  164. >下载模板</el-button
  165. >
  166. <el-upload
  167. :action="baseURL"
  168. :headers="headers"
  169. :disabled="detailData.seeDisabled"
  170. :on-progress="uploading"
  171. :show-file-list="false"
  172. accept=".xls,.xlsx"
  173. multiple
  174. :on-success="importTemplate"
  175. :on-error="uploadError"
  176. style="float: right"
  177. >
  178. <el-button type="primary" size="small" icon="el-icon-upload"
  179. >导 入</el-button
  180. >
  181. </el-upload>
  182. </template>
  183. <template slot-scope="{ row, index }" slot="menu">
  184. <el-button
  185. type="text"
  186. size="small"
  187. @click="rowCell(row, index)"
  188. icon="el-icon-edit"
  189. :disabled="form.status == 0"
  190. >{{ row.$cellEdit ? "保存" : "修改" }}
  191. </el-button>
  192. <el-button
  193. size="small"
  194. icon="el-icon-delete"
  195. type="text"
  196. @click="rowDel(row, index)"
  197. v-show="form.status == 1"
  198. >删 除</el-button>
  199. </template>
  200. </avue-crud>
  201. </basic-container>
  202. <containerTitle title="买赠促销"></containerTitle>
  203. <basic-container style="margin-bottom: 10px">
  204. <avue-crud
  205. :option="customerBuyFree"
  206. v-model="contactsFormBuyFree"
  207. :data="contactsDataBuyFree"
  208. ref="crudContactE"
  209. @row-save="rowSaveBuyFree"
  210. @row-click="handleRowClickBuyFree"
  211. @row-update="rowUpdateBuyFree"
  212. @row-del="rowDelBuyFree"
  213. >
  214. <template slot="code" slot-scope="{ row, index }">
  215. <el-button
  216. size="small"
  217. type="text"
  218. @click="rePick(row, index, 2)"
  219. :disabled="disabled"
  220. class="picker"
  221. style="padding:4px 10px;float:left"
  222. >选择</el-button
  223. >
  224. <span> {{ row.code }}</span>
  225. </template>
  226. <template slot="corpId" slot-scope="{ row, index }">
  227. <crop-select
  228. v-if="row.$cellEdit"
  229. v-model="row.corpId"
  230. :cropIndex="index"
  231. corpType="GYS"
  232. @getCorpData="getcorpFeesId"
  233. :disabled="detailData.seeDisabled"
  234. ></crop-select>
  235. <span v-else>{{ row.corpName }}</span>
  236. </template>
  237. <template slot="menuLeft">
  238. <el-button
  239. type="primary"
  240. icon="el-icon-plus"
  241. size="small"
  242. @click.stop="newBuyFree"
  243. >新增明细</el-button
  244. >
  245. </template>
  246. <template slot-scope="{ row, index }" slot="menu">
  247. <el-button
  248. type="text"
  249. size="small"
  250. @click="rowCellE(row, index)"
  251. icon="el-icon-edit"
  252. >{{ row.$cellEdit ? "保存" : "修改" }}
  253. </el-button>
  254. <el-button
  255. size="small"
  256. icon="el-icon-delete"
  257. type="text"
  258. @click="rowDelBuyFree(row, index)"
  259. v-show="form.status == 1"
  260. >删 除</el-button
  261. >
  262. </template>
  263. </avue-crud>
  264. </basic-container>
  265. </el-form>
  266. <el-dialog
  267. title="导入商品"
  268. append-to-body
  269. class="el-dialogDeep"
  270. :visible.sync="dialogVisible"
  271. width="80%"
  272. top="5vh"
  273. :close-on-click-modal="false"
  274. :destroy-on-close="true"
  275. :close-on-press-escape="false"
  276. @close="closeGoods"
  277. v-dialogdrag
  278. >
  279. <span>
  280. <el-row>
  281. <el-col :span="5">
  282. <div>
  283. <el-scrollbar>
  284. <basic-container style="margin-top:45px">
  285. <avue-tree :option="treeOption" @node-click="nodeClick" />
  286. </basic-container>
  287. </el-scrollbar>
  288. </div>
  289. </el-col>
  290. <el-col :span="19">
  291. <avue-crud
  292. :option="goodsOption"
  293. :table-loading="loading"
  294. :data="goodsList"
  295. ref="goodsCrud"
  296. @refresh-change="refreshChange"
  297. @selection-change="selectionChange"
  298. @row-click="rowClick"
  299. :page.sync="page"
  300. @on-load="onLoad"
  301. @saveColumn="saveGoodsColumn"
  302. @search-change="goodsSearch"
  303. ></avue-crud>
  304. </el-col>
  305. </el-row>
  306. </span>
  307. <span slot="footer" class="dialog-footer">
  308. <el-button @click="dialogVisible = false">取 消</el-button>
  309. <el-button
  310. type="primary"
  311. @click="importGoods"
  312. :disabled="selectionList.length == 0"
  313. >导入</el-button
  314. >
  315. </span>
  316. </el-dialog>
  317. </div>
  318. <el-dialog
  319. append-to-body
  320. title="审批进度"
  321. class="el-dialogDeep"
  322. :visible.sync="checkScheduleDialog"
  323. width="40%"
  324. :close-on-click-modal="false"
  325. :destroy-on-close="true"
  326. :close-on-press-escape="false"
  327. v-dialog-drag
  328. >
  329. <check-schedule
  330. :checkId="checkId"
  331. :batchNo="batchNo"
  332. @choceScheduleFun="choceScheduleFun"
  333. >
  334. </check-schedule>
  335. </el-dialog>
  336. </div>
  337. </template>
  338. <script>
  339. import customerContact from "./configuration/customerContact.json";
  340. import BuyFree from "./configuration/BuyFree.json";
  341. import {
  342. detail,
  343. corpsattn,
  344. typeSave,
  345. getItemdetail,
  346. itemSubmit,
  347. pleaseCheck
  348. } from "@/api/maintenance/salesPolicy";
  349. import {
  350. submit,
  351. delItem,
  352. getDeptLazyTree,
  353. getGoods,
  354. savePurchase,
  355. saveShipping,
  356. getPorts,
  357. getSpecification,
  358. saveSell
  359. } from "@/api/basicData/customerInquiry";
  360. import goodsOption from "./configuration/commodity.json";
  361. import { contrastObj, contrastList } from "@/util/contrastData";
  362. import { getToken } from "@/util/auth";
  363. import { getPurchasePrice } from "@/api/basicData/fees"
  364. import checkSchedule from "@/components/check/checkSchedule";
  365. export default {
  366. props: {
  367. detailData: Object
  368. },
  369. components:{
  370. checkSchedule,
  371. },
  372. data() {
  373. return {
  374. configuration: {
  375. multipleChoices: true,
  376. multiple: true,
  377. collapseTags: false,
  378. placeholder: "请点击右边按钮选择",
  379. dicData: []
  380. },
  381. checkId:'',
  382. batchNo:'',
  383. checkScheduleDialog:false,
  384. form: {},
  385. disabled: false,
  386. customerContact: customerContact,
  387. contactsForm: {},
  388. contactsData: [],
  389. customerBuyFree: BuyFree,
  390. contactsFormBuyFree: {},
  391. contactsDataBuyFree: [],
  392. basicData: {
  393. column: [
  394. {
  395. label: "政策名称",
  396. prop: "cname",
  397. rules: [
  398. {
  399. required: true,
  400. message: " ",
  401. trigger: "blur"
  402. }
  403. ]
  404. },
  405. {
  406. label: "状态",
  407. prop: "status",
  408. type: "select",
  409. dicData: [
  410. {
  411. label: "正常",
  412. value: 0
  413. },
  414. {
  415. label: "停用",
  416. value: 1
  417. }
  418. ],
  419. rules: [
  420. {
  421. required: true,
  422. message: " ",
  423. trigger: "blur"
  424. }
  425. ]
  426. },
  427. {
  428. label: "品牌",
  429. prop: "brand",
  430. rules: [
  431. {
  432. required: true,
  433. message: " ",
  434. trigger: "blur"
  435. }
  436. ]
  437. },
  438. {
  439. label: "操作员",
  440. prop: "createUserName",
  441. disabled: true,
  442. rules: [
  443. {
  444. required: false,
  445. message: " ",
  446. trigger: "blur"
  447. }
  448. ]
  449. },
  450. {
  451. label: "有效期开始时间",
  452. prop: "startTime",
  453. type: "datetime",
  454. rules: [
  455. {
  456. required: true,
  457. message: " ",
  458. trigger: "blur"
  459. }
  460. ]
  461. },
  462. {
  463. label: "有效期结束时间",
  464. prop: "endTime",
  465. type: "datetime",
  466. rules: [
  467. {
  468. required: true,
  469. message: " ",
  470. trigger: "blur"
  471. }
  472. ]
  473. },
  474. {
  475. //多选
  476. label: "代理商",
  477. prop: "corps",
  478. span: 16,
  479. rules: [
  480. {
  481. required: true,
  482. message: " ",
  483. trigger: "blur"
  484. }
  485. ]
  486. },{
  487. //多选
  488. label: "政策类型",
  489. prop: "type",
  490. span: 8,
  491. type: "select",
  492. dicData: [
  493. {
  494. label: "正常",
  495. value: '正常'
  496. },
  497. {
  498. label: "特价",
  499. value: '特价'
  500. }
  501. ],
  502. rules: [
  503. {
  504. required: true,
  505. message: " ",
  506. trigger: "blur"
  507. }
  508. ]
  509. },
  510. {
  511. label: "备注",
  512. type: "textarea",
  513. span: 24,
  514. prop: "remarks",
  515. mock: {
  516. type: "county"
  517. }
  518. }
  519. ]
  520. },
  521. dialogVisible: false,
  522. selectionList: [],
  523. treeDeptId: null,
  524. treeOption: {
  525. nodeKey: "id",
  526. lazy: true,
  527. treeLoad: function(node, resolve) {
  528. const parentId = node.level === 0 ? 0 : node.data.id;
  529. getDeptLazyTree(parentId).then(res => {
  530. resolve(
  531. res.data.data.map(item => {
  532. return {
  533. ...item,
  534. leaf: !item.hasChildren
  535. };
  536. })
  537. );
  538. });
  539. },
  540. addBtn: false,
  541. menu: false,
  542. size: "small",
  543. props: {
  544. label: "title",
  545. value: "value",
  546. children: "children"
  547. }
  548. },
  549. goodsOption: goodsOption,
  550. loading: false,
  551. goodsList: [],
  552. page: {
  553. pageSize: 10,
  554. currentPage: 1,
  555. total: 0
  556. },
  557. contactPage: {
  558. pageSize: 10,
  559. currentPage: 1,
  560. total: 0
  561. },
  562. // 1特价 2买赠
  563. salesType: 1,
  564. reData: null,
  565. oldForm: {},
  566. oldSpecialOffer: [],
  567. oldBuyFree: [],
  568. baseURL: "/api/blade-mocha-item/salespolicy/import-sales-policy",
  569. headers: { "Blade-Auth": "Bearer " + getToken() },
  570. contactLoading: false
  571. };
  572. },
  573. //初始化查询
  574. created() {
  575. if (this.detailData.id) {
  576. this.queryData(this.detailData.id);
  577. } else {
  578. this.form = {
  579. type:'正常'
  580. };
  581. this.contactsData = [];
  582. }
  583. if (this.detailData.check) {
  584. this.batchNo = this.detailData.check.batchNo
  585. }
  586. },
  587. methods: {
  588. choceScheduleFun(){
  589. this.checkScheduleDialog = false
  590. },
  591. queryData(id) {
  592. this.openFullScreen(false, "正在努力的加载...");
  593. detail(id).then(res => {
  594. this.form = res.data.data;
  595. if (this.form.corpNameList) {
  596. this.configuration.dicData = this.form.corpNameList;
  597. }
  598. this.form.corps = this.form.corps.split(",");
  599. // if (res.data.data.specialItemList) this.contactsData = res.data.data.specialItemList
  600. if (res.data.data.presentItemList)
  601. this.contactsDataBuyFree = res.data.data.presentItemList;
  602. this.oldForm = Object.assign({}, this.form);
  603. // this.oldSpecialOffer = this.deepClone(this.contactsData)
  604. this.oldBuyFree = this.deepClone(this.contactsDataBuyFree);
  605. delete this.form.specialItemList;
  606. delete this.form.presentItemList;
  607. this.getItemdetail();
  608. this.openFullScreen(true);
  609. })
  610. },
  611. getItemdetail() {
  612. this.contactLoading = true;
  613. getItemdetail({
  614. current: this.contactPage.currentPage,
  615. size: this.contactPage.pageSize,
  616. pid: this.form.id
  617. })
  618. .then(res => {
  619. this.contactsData = res.data.data.records;
  620. this.contactPage.total = res.data.data.total;
  621. this.customerContact.height = window.innerHeight - 240;
  622. })
  623. .finally(() => {
  624. this.contactLoading = false;
  625. });
  626. },
  627. currentChange(val) {
  628. this.contactPage.currentPage = val;
  629. this.getItemdetail();
  630. },
  631. sizeChange(val) {
  632. this.contactPage.currentPage = 1;
  633. this.contactPage.pageSize = val;
  634. this.getItemdetail();
  635. },
  636. rePick(row, index, type) {
  637. this.reData = {
  638. ...row,
  639. index: index
  640. };
  641. if (type == 1) {
  642. this.newSpecial();
  643. } else {
  644. this.newBuyFree();
  645. }
  646. },
  647. // 新增特价弹窗
  648. newSpecial() {
  649. this.salesType = 1;
  650. this.dialogVisible = !this.dialogVisible;
  651. },
  652. // 买赠弹窗
  653. newBuyFree() {
  654. this.salesType = 2;
  655. this.dialogVisible = !this.dialogVisible;
  656. },
  657. closeGoods() {
  658. this.selectionList = [];
  659. this.treeDeptId = "";
  660. this.reData = null;
  661. },
  662. nodeClick(data) {
  663. this.treeDeptId = data.id;
  664. this.page.currentPage = 1;
  665. this.onLoad(this.page);
  666. },
  667. selectionChange(list) {
  668. this.selectionList = list;
  669. },
  670. rowClick(row) {
  671. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  672. },
  673. goodsSearch(params, done) {
  674. this.onLoad(this.page, params);
  675. done();
  676. },
  677. //商品查询
  678. onLoad(page, params = {}) {
  679. this.loading = true;
  680. getGoods(page.currentPage, page.pageSize, this.treeDeptId, params)
  681. .then(res => {
  682. const data = res.data.data;
  683. this.page.total = data.total;
  684. this.goodsList = data.records;
  685. if (this.page.total) {
  686. this.goodsOption.height = window.innerHeight - 400;
  687. } else {
  688. this.goodsOption.height = window.innerHeight - 400;
  689. }
  690. })
  691. .finally(() => {
  692. this.loading = false;
  693. });
  694. },
  695. // 确认导入商品
  696. importGoods() {
  697. if (this.reData) {
  698. if (this.selectionList.length != 1) {
  699. return this.$message.error("重新选择的时候只能选择一条数据");
  700. } else {
  701. this.selectionList.forEach(e => {
  702. if (this.reData.salesType == 1) {
  703. this.contactsData.forEach(async (item, index) => {
  704. if (index == this.reData.index) {
  705. item.purchasePrice = await this.getPurchasePrice(e);
  706. item.itemId = e.id;
  707. item.code = e.code;
  708. item.cname = e.cname;
  709. item.brand = e.brand;
  710. item.productCategory = e.goodsTypeName;
  711. item.typeno = e.typeno;
  712. item.brandItem = e.brandItem;
  713. item.cartonWeight = e.cartonWeight;
  714. item.cntrVolumn = e.cntrVolumn;
  715. // item.purchasePrice = this.brand.purchasePrice
  716. // item.salesPrice = this.brand.salesPrice
  717. // item.specialOffer = this.brand.specialOffer
  718. // item.updateUserName = this.brand.updateUserName
  719. // item.updateTime = this.brand.updateTime
  720. // item.salesType = this.brand.salesType
  721. }
  722. });
  723. } else {
  724. this.contactsDataBuyFree.forEach(async (item, index) => {
  725. item.itemId = e.id;
  726. item.code = e.code;
  727. item.cname = e.cname;
  728. item.brand = e.brand;
  729. item.productCategory = e.goodsTypeName;
  730. item.typeno = e.typeno;
  731. item.brandItem = e.brandItem;
  732. item.cartonWeight = e.cartonWeight;
  733. item.cntrVolumn = e.cntrVolumn;
  734. // item.purchasePrice = this.brand.purchasePrice
  735. // item.salesPrice = this.brand.salesPrice
  736. // item.salesPrice = this.brand.purchaseAmount
  737. // item.updateUserName = this.brand.salesVolume
  738. // item.updateUserName = this.brand.updateUserName
  739. // item.updateTime = this.brand.updateTime
  740. // item.salesType = this.brand.salesType
  741. });
  742. }
  743. });
  744. }
  745. } else {
  746. if (this.salesType == 1) {
  747. this.selectionList.forEach(async item => {
  748. this.contactsData.push({
  749. purchasePrice: await this.getPurchasePrice(item),
  750. itemId: item.id,
  751. code: item.code,
  752. brand: item.brand,
  753. productCategory: item.goodsTypeName,
  754. typeno: item.typeno,
  755. brandItem: item.brandItem,
  756. corpId: item.corpId,
  757. corpName: item.corpName,
  758. salesPrice: "",
  759. specialOffer: "",
  760. updateUserName: "",
  761. updateTime: "",
  762. salesType: "1",
  763. cntrVolumn: item.cntrVolumn,
  764. cartonWeight: item.cartonWeight,
  765. });
  766. });
  767. } else if (this.salesType == 2) {
  768. this.selectionList.forEach(item => {
  769. this.contactsDataBuyFree.push({
  770. itemId: item.id,
  771. code: item.code,
  772. brand: item.brand,
  773. productCategory: item.goodsTypeName,
  774. typeno: item.typeno,
  775. brandItem: item.brandItem,
  776. corpName: item.corpName,
  777. corpId: item.corpId,
  778. purchasePrice: "",
  779. salesPrice: "",
  780. purchaseAmount: "",
  781. salesVolume: "",
  782. updateUserName: "",
  783. updateTime: "",
  784. salesType: "2",
  785. cntrVolumn: item.cntrVolumn,
  786. cartonWeight: item.cartonWeight,
  787. });
  788. });
  789. }
  790. }
  791. this.dialogVisible = false;
  792. },
  793. //买赠列表信息保存触发
  794. rowSaveBuyFree(row, done, loading) {
  795. // this.contactsData.push(row)
  796. done();
  797. },
  798. //买赠列表点击行可编辑
  799. handleRowClickBuyFree(row, event, column) {
  800. },
  801. //买赠列表修改信息触发
  802. rowUpdateBuyFree(row, index, done, loading) {
  803. done(row);
  804. },
  805. //买赠列表删除信息触发
  806. rowDelBuyFree(row, index, donerowDel) {
  807. this.$confirm("确定将选择数据删除?", {
  808. confirmButtonText: "确定",
  809. cancelButtonText: "取消",
  810. type: "warning"
  811. }).then(() => {
  812. //商品判断是否需要调用删除接口
  813. if (row.id) {
  814. corpsattn(row.id).then(res => {
  815. this.$message({
  816. type: "success",
  817. message: "操作成功!"
  818. });
  819. this.contactsDataBuyFree.splice(index, 1);
  820. });
  821. } else {
  822. this.$message({
  823. type: "success",
  824. message: "操作成功!"
  825. });
  826. this.contactsDataBuyFree.splice(index, 1);
  827. }
  828. });
  829. },
  830. //新增商品信息保存触发
  831. rowSave(row, done, loading) {
  832. console.log(row);
  833. console.log(this.contactsData);
  834. // this.contactsData.push(row)
  835. done();
  836. },
  837. //点击行可编辑
  838. handleRowClick(row, event, column) {
  839. console.log(row.$index);
  840. },
  841. //商品编辑
  842. rowCell(row, index) {
  843. if (row.$cellEdit && this.form.id) {
  844. itemSubmit({...row,pid: this.form.id}).then(res => {
  845. this.$message.success('保存成功')
  846. this.$refs.crudContact.rowCell(row, index);
  847. })
  848. } else {
  849. this.$refs.crudContact.rowCell(row, index);
  850. }
  851. },
  852. //买赠编辑
  853. rowCellE(row, index) {
  854. console.log(row);
  855. this.$refs.crudContactE.rowCell(row, index);
  856. },
  857. //修改商品信息触发
  858. rowUpdate(row, index, done, loading) {
  859. done(row);
  860. },
  861. //删除商品信息触发
  862. rowDel(row, index, donerowDel) {
  863. this.$confirm("确定将选择数据删除?", {
  864. confirmButtonText: "确定",
  865. cancelButtonText: "取消",
  866. type: "warning"
  867. }).then(() => {
  868. //商品判断是否需要调用删除接口
  869. if (row.id) {
  870. corpsattn(row.id).then(res => {
  871. this.$message({
  872. type: "success",
  873. message: "操作成功!"
  874. });
  875. this.contactsData.splice(index, 1);
  876. });
  877. } else {
  878. this.$message({
  879. type: "success",
  880. message: "操作成功!"
  881. });
  882. this.contactsData.splice(index, 1);
  883. }
  884. });
  885. },
  886. //请核数据
  887. pleaseCheck(){
  888. this.$confirm("是否确认提交审批?", {
  889. confirmButtonText: "确定",
  890. cancelButtonText: "取消",
  891. type: "warning"
  892. }).then(() => {
  893. for (let item in this.contactsData) {
  894. if (!this.contactsData[item].corpId) {
  895. return this.$message.error('特价明细第' + (Number(item) + 1) + '行供应商不能为空')
  896. }
  897. }
  898. for (let item in this.contactsDataBuyFree) {
  899. if (!this.contactsDataBuyFree[item].corpId) {
  900. return this.$message.error('买赠明细第' + (Number(item) + 1) + '行供应商不能为空')
  901. }
  902. }
  903. this.form.corps = this.form.corps.join(",");
  904. this.form.specialItemList = this.contactsData;
  905. this.form.presentItemList = this.contactsDataBuyFree;
  906. this.openFullScreen(false, "正在努力的加载...");
  907. typeSave(this.form).then(res => {
  908. const data = {
  909. id : this.form.id,
  910. checkType: 'xszc',
  911. url: '/maintenance/salesPolicy/index',
  912. pageStatus:"this.$store.getters.domSaleStatus",
  913. pageLabel:"销售政策",
  914. checkFlag: 2,
  915. }
  916. pleaseCheck(data).then(res=>{
  917. this.$message({
  918. type: "success",
  919. message: "请核成功!"
  920. });
  921. this.queryData(this.form.id);
  922. })
  923. });
  924. })
  925. },
  926. //修改提交触发
  927. editCustomer() {
  928. this.$refs["form"].validate(valid => {
  929. if (valid) {
  930. for (let item in this.contactsData) {
  931. if (!this.contactsData[item].corpId) {
  932. return this.$message.error('特价明细第' + (Number(item) + 1) + '行供应商不能为空')
  933. }
  934. }
  935. for (let item in this.contactsDataBuyFree) {
  936. if (!this.contactsDataBuyFree[item].corpId) {
  937. return this.$message.error('买赠明细第' + (Number(item) + 1) + '行供应商不能为空')
  938. }
  939. }
  940. this.form.corps = this.form.corps.join(",");
  941. this.form.specialItemList = this.contactsData;
  942. this.form.presentItemList = this.contactsDataBuyFree;
  943. this.openFullScreen(false, "正在努力的加载...");
  944. typeSave(this.form).then(res => {
  945. this.$message({
  946. type: "success",
  947. message: this.form.id ? "修改成功!" : "新增成功!"
  948. });
  949. // this.backToList()
  950. this.queryData(res.data.data.id);
  951. });
  952. } else {
  953. return false;
  954. }
  955. });
  956. },
  957. //返回列表
  958. backToList() {
  959. this.$emit("goBack");
  960. },
  961. async saveGoodsColumn() {
  962. // const inSave = await this.saveColumnData(
  963. // this.getColumnName(26),
  964. // this.goodsOption
  965. // );
  966. // if (inSave) {
  967. // this.$message.success("保存成功");
  968. // //关闭窗口
  969. // this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  970. // }
  971. },
  972. //遮罩层
  973. openFullScreen(res, text) {
  974. const loading = this.$loading({
  975. lock: true,
  976. text: text,
  977. spinner: "el-icon-loading",
  978. background: "rgba(0, 0, 0, 0.7)"
  979. });
  980. if (res === true) loading.close();
  981. },
  982. getcorpId(row) {
  983. this.contactsData[row.index].corpId = row.id;
  984. },
  985. getcorpFeesId(row) {
  986. this.contactsDataBuyFree[row.index].corpId = row.id;
  987. },
  988. // 下载模板
  989. downloadHandle() {
  990. this.$confirm("是否下载模板文件?", "提示", {
  991. confirmButtonText: "确定",
  992. cancelButtonText: "取消",
  993. type: "warning"
  994. })
  995. .then(() => {
  996. window.open(
  997. `/api/blade-mocha-item/salespolicy/export-sales-policy?${
  998. this.website.tokenHeader
  999. }=${getToken()}`
  1000. );
  1001. })
  1002. .catch(() => {
  1003. this.$message({
  1004. type: "info",
  1005. message: "已取消"
  1006. });
  1007. });
  1008. },
  1009. //文件上传时
  1010. uploading(event, file, fileList) {
  1011. this.openFullScreen(false, "文件正在解析中");
  1012. },
  1013. importTemplate(res, file) {
  1014. this.openFullScreen(true);
  1015. let contactsData = [];
  1016. contactsData = res.data;
  1017. this.contactsData = this.contactsData.concat(contactsData);
  1018. // console.log(res.data)
  1019. },
  1020. uploadError(err, file, fileList) {
  1021. this.openFullScreen(true);
  1022. this.$message.error(JSON.parse(err.message).msg);
  1023. },
  1024. getCorpList(data) {
  1025. let arr = [];
  1026. data.map(e => {
  1027. arr.push(e.id);
  1028. });
  1029. this.form.corps = arr;
  1030. },
  1031. async getPurchasePrice(row) {
  1032. let data;
  1033. await getPurchasePrice({code: row.code}).then(res => {
  1034. data = res.data.data.length > 0? res.data.data[0].purchasePrice: 0
  1035. })
  1036. return data;
  1037. },
  1038. }
  1039. };
  1040. </script>
  1041. <style lang="scss" scoped>
  1042. .back-icon {
  1043. line-height: 64px;
  1044. font-size: 20px;
  1045. margin-right: 8px;
  1046. }
  1047. ::v-deep .el-form-item {
  1048. margin-bottom: 0;
  1049. }
  1050. .el-dialogDeep {
  1051. ::v-deep .el-dialog {
  1052. margin: 1vh auto 0 !important;
  1053. padding-bottom: 10px !important;
  1054. .el-dialog__body,
  1055. .el-dialog__footer {
  1056. padding-bottom: 0 !important;
  1057. padding-top: 0 !important;
  1058. }
  1059. }
  1060. }
  1061. ::v-deep .el-form-item {
  1062. margin-bottom: 0;
  1063. }
  1064. ::v-deep .el-form-item__content {
  1065. line-height: 32px;
  1066. }
  1067. </style>