detailsPageEdit.vue 28 KB

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