detailsPageEdit.vue 34 KB

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