detailsPageEdit.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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. :multiple="true"
  73. :collapseTags="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. name: "detailsPage",
  335. props: {
  336. detailData: Object
  337. },
  338. data() {
  339. return {
  340. configuration: {
  341. multipleChoices: true,
  342. multiple: true,
  343. collapseTags: false,
  344. placeholder: "请点击右边按钮选择",
  345. dicData: []
  346. },
  347. form: {},
  348. disabled: false,
  349. customerContact: customerContact,
  350. contactsForm: {},
  351. contactsData: [],
  352. customerBuyFree: BuyFree,
  353. contactsFormBuyFree: {},
  354. contactsDataBuyFree: [],
  355. basicData: {
  356. column: [
  357. {
  358. label: "政策名称",
  359. prop: "cname",
  360. rules: [
  361. {
  362. required: true,
  363. message: " ",
  364. trigger: "blur"
  365. }
  366. ]
  367. },
  368. {
  369. label: "状态",
  370. prop: "status",
  371. type: "select",
  372. dicData: [
  373. {
  374. label: "正常",
  375. value: 0
  376. },
  377. {
  378. label: "停用",
  379. value: 1
  380. }
  381. ],
  382. rules: [
  383. {
  384. required: true,
  385. message: " ",
  386. trigger: "blur"
  387. }
  388. ]
  389. },
  390. {
  391. label: "品牌",
  392. prop: "brand",
  393. rules: [
  394. {
  395. required: true,
  396. message: " ",
  397. trigger: "blur"
  398. }
  399. ]
  400. },
  401. {
  402. label: "操作员",
  403. prop: "createUserName",
  404. disabled: true,
  405. rules: [
  406. {
  407. required: false,
  408. message: " ",
  409. trigger: "blur"
  410. }
  411. ]
  412. },
  413. {
  414. label: "有效期开始时间",
  415. prop: "startTime",
  416. type: "datetime",
  417. rules: [
  418. {
  419. required: true,
  420. message: " ",
  421. trigger: "blur"
  422. }
  423. ]
  424. },
  425. {
  426. label: "有效期结束时间",
  427. prop: "endTime",
  428. type: "datetime",
  429. rules: [
  430. {
  431. required: true,
  432. message: " ",
  433. trigger: "blur"
  434. }
  435. ]
  436. },
  437. {
  438. //多选
  439. label: "代理商",
  440. prop: "corps",
  441. span: 16,
  442. rules: [
  443. {
  444. required: true,
  445. message: " ",
  446. trigger: "blur"
  447. }
  448. ]
  449. },
  450. {
  451. label: "备注",
  452. type: "textarea",
  453. span: 24,
  454. prop: "remarks",
  455. mock: {
  456. type: "county"
  457. }
  458. }
  459. ]
  460. },
  461. dialogVisible: false,
  462. selectionList: [],
  463. treeDeptId: null,
  464. treeOption: {
  465. nodeKey: "id",
  466. lazy: true,
  467. treeLoad: function(node, resolve) {
  468. const parentId = node.level === 0 ? 0 : node.data.id;
  469. getDeptLazyTree(parentId).then(res => {
  470. resolve(
  471. res.data.data.map(item => {
  472. return {
  473. ...item,
  474. leaf: !item.hasChildren
  475. };
  476. })
  477. );
  478. });
  479. },
  480. addBtn: false,
  481. menu: false,
  482. size: "small",
  483. props: {
  484. label: "title",
  485. value: "value",
  486. children: "children"
  487. }
  488. },
  489. goodsOption: goodsOption,
  490. loading: false,
  491. goodsList: [],
  492. page: {
  493. pageSize: 10,
  494. currentPage: 1,
  495. total: 0
  496. },
  497. contactPage: {
  498. pageSize: 10,
  499. currentPage: 1,
  500. total: 0
  501. },
  502. // 1特价 2买赠
  503. salesType: 1,
  504. reData: null,
  505. oldForm: {},
  506. oldSpecialOffer: [],
  507. oldBuyFree: [],
  508. baseURL: "/api/blade-mocha-item/salespolicy/import-sales-policy",
  509. headers: { "Blade-Auth": "Bearer " + getToken() },
  510. contactLoading: false
  511. };
  512. },
  513. //初始化查询
  514. created() {
  515. if (this.detailData.id) {
  516. this.queryData(this.detailData.id);
  517. } else {
  518. this.form = {};
  519. this.contactsData = [];
  520. }
  521. },
  522. watch: {
  523. $route(to, from) {
  524. if (this.detailData.id) {
  525. } else {
  526. this.form = {};
  527. }
  528. }
  529. },
  530. methods: {
  531. queryData(id) {
  532. this.openFullScreen(false, "正在努力的加载...");
  533. detail(id)
  534. .then(res => {
  535. this.form = res.data.data;
  536. if (this.form.corpNameList) {
  537. this.configuration.dicData = this.form.corpNameList;
  538. }
  539. this.form.corps = this.form.corps.split(",");
  540. // if (res.data.data.specialItemList) this.contactsData = res.data.data.specialItemList
  541. if (res.data.data.presentItemList)
  542. this.contactsDataBuyFree = res.data.data.presentItemList;
  543. this.oldForm = Object.assign({}, this.form);
  544. // this.oldSpecialOffer = this.deepClone(this.contactsData)
  545. this.oldBuyFree = this.deepClone(this.contactsDataBuyFree);
  546. delete this.form.specialItemList;
  547. delete this.form.presentItemList;
  548. this.getItemdetail();
  549. })
  550. .finally(() => {
  551. this.openFullScreen(true);
  552. });
  553. },
  554. getItemdetail() {
  555. this.contactLoading = true;
  556. getItemdetail({
  557. current: this.contactPage.currentPage,
  558. size: this.contactPage.pageSize,
  559. pid: this.form.id
  560. })
  561. .then(res => {
  562. this.contactsData = res.data.data.records;
  563. this.contactPage.total = res.data.data.total;
  564. this.customerContact.height = window.innerHeight - 240;
  565. })
  566. .finally(() => {
  567. this.contactLoading = false;
  568. });
  569. },
  570. currentChange(val) {
  571. this.contactPage.currentPage = val;
  572. this.getItemdetail();
  573. },
  574. sizeChange(val) {
  575. this.contactPage.currentPage = 1;
  576. this.contactPage.pageSize = val;
  577. this.getItemdetail();
  578. },
  579. rePick(row, index, type) {
  580. this.reData = {
  581. ...row,
  582. index: index
  583. };
  584. if (type == 1) {
  585. this.newSpecial();
  586. } else {
  587. this.newBuyFree();
  588. }
  589. },
  590. // 新增特价弹窗
  591. newSpecial() {
  592. this.salesType = 1;
  593. this.dialogVisible = !this.dialogVisible;
  594. },
  595. // 买赠弹窗
  596. newBuyFree() {
  597. this.salesType = 2;
  598. this.dialogVisible = !this.dialogVisible;
  599. },
  600. closeGoods() {
  601. this.selectionList = [];
  602. this.treeDeptId = "";
  603. this.reData = null;
  604. },
  605. nodeClick(data) {
  606. this.treeDeptId = data.id;
  607. this.page.currentPage = 1;
  608. this.onLoad(this.page);
  609. },
  610. selectionChange(list) {
  611. this.selectionList = list;
  612. },
  613. rowClick(row) {
  614. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  615. },
  616. goodsSearch(params, done) {
  617. this.onLoad(this.page, params);
  618. done();
  619. },
  620. //商品查询
  621. onLoad(page, params = {}) {
  622. this.loading = true;
  623. getGoods(page.currentPage, page.pageSize, this.treeDeptId, params)
  624. .then(res => {
  625. const data = res.data.data;
  626. this.page.total = data.total;
  627. this.goodsList = data.records;
  628. if (this.page.total) {
  629. this.goodsOption.height = window.innerHeight - 400;
  630. } else {
  631. this.goodsOption.height = window.innerHeight - 400;
  632. }
  633. })
  634. .finally(() => {
  635. this.loading = false;
  636. });
  637. },
  638. // 确认导入商品
  639. importGoods() {
  640. if (this.reData) {
  641. if (this.selectionList.length != 1) {
  642. return this.$message.error("重新选择的时候只能选择一条数据");
  643. } else {
  644. this.selectionList.forEach(e => {
  645. if (this.reData.salesType == 1) {
  646. this.contactsData.forEach(async (item, index) => {
  647. if (index == this.reData.index) {
  648. item.purchasePrice = await this.getPurchasePrice(e);
  649. item.itemId = e.id;
  650. item.code = e.code;
  651. item.cname = e.cname;
  652. item.brand = e.brand;
  653. item.productCategory = e.goodsTypeName;
  654. item.typeno = e.typeno;
  655. item.brandItem = e.brandItem;
  656. // item.purchasePrice = this.brand.purchasePrice
  657. // item.salesPrice = this.brand.salesPrice
  658. // item.specialOffer = this.brand.specialOffer
  659. // item.updateUserName = this.brand.updateUserName
  660. // item.updateTime = this.brand.updateTime
  661. // item.salesType = this.brand.salesType
  662. }
  663. });
  664. } else {
  665. this.contactsDataBuyFree.forEach(async (item, index) => {
  666. item.itemId = e.id;
  667. item.code = e.code;
  668. item.cname = e.cname;
  669. item.brand = e.brand;
  670. item.productCategory = e.goodsTypeName;
  671. item.typeno = e.typeno;
  672. item.brandItem = e.brandItem;
  673. // item.purchasePrice = this.brand.purchasePrice
  674. // item.salesPrice = this.brand.salesPrice
  675. // item.salesPrice = this.brand.purchaseAmount
  676. // item.updateUserName = this.brand.salesVolume
  677. // item.updateUserName = this.brand.updateUserName
  678. // item.updateTime = this.brand.updateTime
  679. // item.salesType = this.brand.salesType
  680. });
  681. }
  682. });
  683. }
  684. } else {
  685. if (this.salesType == 1) {
  686. this.selectionList.forEach(async item => {
  687. this.contactsData.push({
  688. purchasePrice: await this.getPurchasePrice(item),
  689. itemId: item.id,
  690. code: item.code,
  691. brand: item.brand,
  692. productCategory: item.goodsTypeName,
  693. typeno: item.typeno,
  694. brandItem: item.brandItem,
  695. corpId: item.corpId,
  696. corpName: item.corpName,
  697. salesPrice: "",
  698. specialOffer: "",
  699. updateUserName: "",
  700. updateTime: "",
  701. salesType: "1"
  702. });
  703. });
  704. } else if (this.salesType == 2) {
  705. this.selectionList.forEach(item => {
  706. this.contactsDataBuyFree.push({
  707. itemId: item.id,
  708. code: item.code,
  709. brand: item.brand,
  710. productCategory: item.goodsTypeName,
  711. typeno: item.typeno,
  712. brandItem: item.brandItem,
  713. corpName: item.corpName,
  714. purchasePrice: "",
  715. salesPrice: "",
  716. purchaseAmount: "",
  717. salesVolume: "",
  718. updateUserName: "",
  719. updateTime: "",
  720. salesType: "2"
  721. });
  722. });
  723. }
  724. }
  725. this.dialogVisible = false;
  726. console.log(this.contactsData);
  727. },
  728. //买赠列表信息保存触发
  729. rowSaveBuyFree(row, done, loading) {
  730. console.log(row);
  731. console.log(this.contactsData);
  732. // this.contactsData.push(row)
  733. done();
  734. },
  735. //买赠列表点击行可编辑
  736. handleRowClickBuyFree(row, event, column) {
  737. console.log(row.$index);
  738. },
  739. //买赠列表修改信息触发
  740. rowUpdateBuyFree(row, index, done, loading) {
  741. done(row);
  742. },
  743. //买赠列表删除信息触发
  744. rowDelBuyFree(row, index, donerowDel) {
  745. this.$confirm("确定将选择数据删除?", {
  746. confirmButtonText: "确定",
  747. cancelButtonText: "取消",
  748. type: "warning"
  749. }).then(() => {
  750. //商品判断是否需要调用删除接口
  751. if (row.id) {
  752. corpsattn(row.id).then(res => {
  753. this.$message({
  754. type: "success",
  755. message: "操作成功!"
  756. });
  757. this.contactsDataBuyFree.splice(index, 1);
  758. });
  759. } else {
  760. this.$message({
  761. type: "success",
  762. message: "操作成功!"
  763. });
  764. this.contactsDataBuyFree.splice(index, 1);
  765. }
  766. });
  767. },
  768. //新增商品信息保存触发
  769. rowSave(row, done, loading) {
  770. console.log(row);
  771. console.log(this.contactsData);
  772. // this.contactsData.push(row)
  773. done();
  774. },
  775. //点击行可编辑
  776. handleRowClick(row, event, column) {
  777. console.log(row.$index);
  778. },
  779. //商品编辑
  780. rowCell(row, index) {
  781. if (row.$cellEdit && this.form.id) {
  782. itemSubmit({...row,pid: this.form.id}).then(res => {
  783. this.$message.success('保存成功')
  784. this.$refs.crudContact.rowCell(row, index);
  785. })
  786. } else {
  787. this.$refs.crudContact.rowCell(row, index);
  788. }
  789. },
  790. //买赠编辑
  791. rowCellE(row, index) {
  792. console.log(row);
  793. this.$refs.crudContactE.rowCell(row, index);
  794. },
  795. //修改商品信息触发
  796. rowUpdate(row, index, done, loading) {
  797. done(row);
  798. },
  799. //删除商品信息触发
  800. rowDel(row, index, donerowDel) {
  801. this.$confirm("确定将选择数据删除?", {
  802. confirmButtonText: "确定",
  803. cancelButtonText: "取消",
  804. type: "warning"
  805. }).then(() => {
  806. //商品判断是否需要调用删除接口
  807. if (row.id) {
  808. corpsattn(row.id).then(res => {
  809. this.$message({
  810. type: "success",
  811. message: "操作成功!"
  812. });
  813. this.contactsData.splice(index, 1);
  814. });
  815. } else {
  816. this.$message({
  817. type: "success",
  818. message: "操作成功!"
  819. });
  820. this.contactsData.splice(index, 1);
  821. }
  822. });
  823. },
  824. //修改提交触发
  825. editCustomer() {
  826. this.$refs["form"].validate(valid => {
  827. if (valid) {
  828. this.form.corps = this.form.corps.join(",");
  829. this.form.specialItemList = this.contactsData;
  830. this.form.presentItemList = this.contactsDataBuyFree;
  831. this.openFullScreen(false, "正在努力的加载...");
  832. typeSave(this.form).then(res => {
  833. this.$message({
  834. type: "success",
  835. message: this.form.id ? "修改成功!" : "新增成功!"
  836. });
  837. // this.backToList()
  838. this.queryData(res.data.data.id);
  839. });
  840. } else {
  841. return false;
  842. }
  843. });
  844. },
  845. //返回列表
  846. backToList() {
  847. this.$emit("goBack");
  848. },
  849. async saveGoodsColumn() {
  850. // const inSave = await this.saveColumnData(
  851. // this.getColumnName(26),
  852. // this.goodsOption
  853. // );
  854. // if (inSave) {
  855. // this.$message.success("保存成功");
  856. // //关闭窗口
  857. // this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  858. // }
  859. },
  860. //遮罩层
  861. openFullScreen(res, text) {
  862. const loading = this.$loading({
  863. lock: true,
  864. text: text,
  865. spinner: "el-icon-loading",
  866. background: "rgba(0, 0, 0, 0.7)"
  867. });
  868. if (res === true) loading.close();
  869. },
  870. getcorpId(row) {
  871. this.contactsData[row.index].corpId = row.id;
  872. },
  873. getcorpFeesId(row) {
  874. this.contactsDataBuyFree[row.index].corpId = row.id;
  875. },
  876. // 下载模板
  877. downloadHandle() {
  878. this.$confirm("是否下载模板文件?", "提示", {
  879. confirmButtonText: "确定",
  880. cancelButtonText: "取消",
  881. type: "warning"
  882. })
  883. .then(() => {
  884. window.open(
  885. `/api/blade-mocha-item/salespolicy/export-sales-policy?${
  886. this.website.tokenHeader
  887. }=${getToken()}`
  888. );
  889. })
  890. .catch(() => {
  891. this.$message({
  892. type: "info",
  893. message: "已取消"
  894. });
  895. });
  896. },
  897. //文件上传时
  898. uploading(event, file, fileList) {
  899. this.openFullScreen(false, "文件正在解析中");
  900. },
  901. importTemplate(res, file) {
  902. this.openFullScreen(true);
  903. let contactsData = [];
  904. contactsData = res.data;
  905. this.contactsData = this.contactsData.concat(contactsData);
  906. // console.log(res.data)
  907. },
  908. uploadError(err, file, fileList) {
  909. this.openFullScreen(true);
  910. this.$message.error(JSON.parse(err.message).msg);
  911. },
  912. getCorpList(data) {
  913. let arr = [];
  914. data.map(e => {
  915. arr.push(e.id);
  916. });
  917. this.form.corps = arr;
  918. },
  919. async getPurchasePrice(row) {
  920. let data;
  921. await getPurchasePrice({code: row.code}).then(res => {
  922. data = res.data.data.length > 0? res.data.data[0].purchasePrice: 0
  923. })
  924. return data;
  925. },
  926. }
  927. };
  928. </script>
  929. <style lang="scss" scoped>
  930. .back-icon {
  931. line-height: 64px;
  932. font-size: 20px;
  933. margin-right: 8px;
  934. }
  935. ::v-deep .el-form-item {
  936. margin-bottom: 0;
  937. }
  938. .el-dialogDeep {
  939. ::v-deep .el-dialog {
  940. margin: 1vh auto 0 !important;
  941. padding-bottom: 10px !important;
  942. .el-dialog__body,
  943. .el-dialog__footer {
  944. padding-bottom: 0 !important;
  945. padding-top: 0 !important;
  946. }
  947. }
  948. }
  949. ::v-deep .el-form-item {
  950. margin-bottom: 0;
  951. }
  952. ::v-deep .el-form-item__content {
  953. line-height: 32px;
  954. }
  955. </style>