detailsPageEdit.vue 30 KB

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