detailsPageEdit.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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. corpType="KH"
  74. style="width: 100%"
  75. @getCorpList="getCorpList"
  76. ></crop-select>
  77. <!-- <selectComponent v-else-if="item.prop === 'corps'" v-model="form[item.prop]"-->
  78. <!-- :configuration="configuration" style="width: 100%"/>-->
  79. <el-input
  80. type="textarea"
  81. v-else-if="item.type === 'textarea'"
  82. v-model="form[item.prop]"
  83. size="small"
  84. autocomplete="off"
  85. :disabled="item.disabled"
  86. ></el-input>
  87. <el-input
  88. type="age"
  89. v-else
  90. v-model="form[item.prop]"
  91. size="small"
  92. autocomplete="off"
  93. :disabled="item.disabled ? item.disabled : false"
  94. ></el-input>
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. </basic-container>
  99. <containerTitle title="特价促销"></containerTitle>
  100. <basic-container style="margin-bottom: 10px">
  101. <avue-crud
  102. :table-loading="contactLoading"
  103. :page.sync="contactPage"
  104. :option="customerContact"
  105. v-model="contactsForm"
  106. :data="contactsData"
  107. ref="crudContact"
  108. @current-change="currentChange"
  109. @size-change="sizeChange"
  110. @row-save="rowSave"
  111. @row-click="handleRowClick"
  112. @row-update="rowUpdate"
  113. @row-del="rowDel"
  114. >
  115. <template slot="code" slot-scope="{ row, index }">
  116. <el-button
  117. size="small"
  118. type="text"
  119. @click="rePick(row, index, 1)"
  120. :disabled="disabled"
  121. class="picker"
  122. style="padding:4px 10px;float:left"
  123. >选择</el-button
  124. >
  125. <span> {{ row.code }}</span>
  126. </template>
  127. <template slot="corpId" slot-scope="{ row, index }">
  128. <crop-select
  129. v-if="row.$cellEdit"
  130. v-model="row.corpId"
  131. :cropIndex="index"
  132. corpType="GYS"
  133. @getCorpData="getcorpId"
  134. :disabled="detailData.seeDisabled"
  135. ></crop-select>
  136. <span v-else>{{ row.corpName }}</span>
  137. </template>
  138. <template slot="menuLeft">
  139. <el-button
  140. type="primary"
  141. icon="el-icon-plus"
  142. size="small"
  143. @click.stop="newSpecial"
  144. >新增明细</el-button
  145. >
  146. <el-button
  147. type="primary"
  148. size="small"
  149. icon="el-icon-download"
  150. @click="downloadHandle"
  151. >下载模板</el-button
  152. >
  153. <el-upload
  154. :action="baseURL"
  155. :headers="headers"
  156. :disabled="detailData.seeDisabled"
  157. :on-progress="uploading"
  158. :show-file-list="false"
  159. accept=".xls,.xlsx"
  160. multiple
  161. :on-success="importTemplate"
  162. :on-error="uploadError"
  163. style="float: right"
  164. >
  165. <el-button type="primary" size="small" icon="el-icon-upload"
  166. >导 入</el-button
  167. >
  168. </el-upload>
  169. </template>
  170. <template slot-scope="{ row, index }" slot="menu">
  171. <el-button
  172. type="text"
  173. size="small"
  174. @click="rowCell(row, index)"
  175. icon="el-icon-edit"
  176. :disabled="form.status == 0"
  177. >{{ row.$cellEdit ? "保存" : "修改" }}
  178. </el-button>
  179. <el-button
  180. size="small"
  181. icon="el-icon-delete"
  182. type="text"
  183. @click="rowDel(row, index)"
  184. v-show="form.status == 1"
  185. >删 除</el-button>
  186. </template>
  187. </avue-crud>
  188. </basic-container>
  189. <containerTitle title="买赠促销"></containerTitle>
  190. <basic-container style="margin-bottom: 10px">
  191. <avue-crud
  192. :option="customerBuyFree"
  193. v-model="contactsFormBuyFree"
  194. :data="contactsDataBuyFree"
  195. ref="crudContactE"
  196. @row-save="rowSaveBuyFree"
  197. @row-click="handleRowClickBuyFree"
  198. @row-update="rowUpdateBuyFree"
  199. @row-del="rowDelBuyFree"
  200. >
  201. <template slot="code" slot-scope="{ row, index }">
  202. <el-button
  203. size="small"
  204. type="text"
  205. @click="rePick(row, index, 2)"
  206. :disabled="disabled"
  207. class="picker"
  208. style="padding:4px 10px;float:left"
  209. >选择</el-button
  210. >
  211. <span> {{ row.code }}</span>
  212. </template>
  213. <template slot="corpId" slot-scope="{ row, index }">
  214. <crop-select
  215. v-if="row.$cellEdit"
  216. v-model="row.corpId"
  217. :cropIndex="index"
  218. corpType="GYS"
  219. @getCorpData="getcorpFeesId"
  220. :disabled="detailData.seeDisabled"
  221. ></crop-select>
  222. <span v-else>{{ row.corpName }}</span>
  223. </template>
  224. <template slot="menuLeft">
  225. <el-button
  226. type="primary"
  227. icon="el-icon-plus"
  228. size="small"
  229. @click.stop="newBuyFree"
  230. >新增明细</el-button
  231. >
  232. </template>
  233. <template slot-scope="{ row, index }" slot="menu">
  234. <el-button
  235. type="text"
  236. size="small"
  237. @click="rowCellE(row, index)"
  238. icon="el-icon-edit"
  239. >{{ row.$cellEdit ? "保存" : "修改" }}
  240. </el-button>
  241. <el-button
  242. size="small"
  243. icon="el-icon-delete"
  244. type="text"
  245. @click="rowDelBuyFree(row, index)"
  246. v-show="form.status == 1"
  247. >删 除</el-button
  248. >
  249. </template>
  250. </avue-crud>
  251. </basic-container>
  252. </el-form>
  253. <el-dialog
  254. title="导入商品"
  255. append-to-body
  256. class="el-dialogDeep"
  257. :visible.sync="dialogVisible"
  258. width="80%"
  259. top="5vh"
  260. :close-on-click-modal="false"
  261. :destroy-on-close="true"
  262. :close-on-press-escape="false"
  263. @close="closeGoods"
  264. v-dialogdrag
  265. >
  266. <span>
  267. <el-row>
  268. <el-col :span="5">
  269. <div>
  270. <el-scrollbar>
  271. <basic-container style="margin-top:45px">
  272. <avue-tree :option="treeOption" @node-click="nodeClick" />
  273. </basic-container>
  274. </el-scrollbar>
  275. </div>
  276. </el-col>
  277. <el-col :span="19">
  278. <avue-crud
  279. :option="goodsOption"
  280. :table-loading="loading"
  281. :data="goodsList"
  282. ref="goodsCrud"
  283. @refresh-change="refreshChange"
  284. @selection-change="selectionChange"
  285. @row-click="rowClick"
  286. :page.sync="page"
  287. @on-load="onLoad"
  288. @saveColumn="saveGoodsColumn"
  289. @search-change="goodsSearch"
  290. ></avue-crud>
  291. </el-col>
  292. </el-row>
  293. </span>
  294. <span slot="footer" class="dialog-footer">
  295. <el-button @click="dialogVisible = false">取 消</el-button>
  296. <el-button
  297. type="primary"
  298. @click="importGoods"
  299. :disabled="selectionList.length == 0"
  300. >导入</el-button
  301. >
  302. </span>
  303. </el-dialog>
  304. </div>
  305. </div>
  306. </template>
  307. <script>
  308. import customerContact from "./configuration/customerContact.json";
  309. import BuyFree from "./configuration/BuyFree.json";
  310. import {
  311. detail,
  312. corpsattn,
  313. typeSave,
  314. getItemdetail,
  315. itemSubmit
  316. } from "@/api/maintenance/salesPolicy";
  317. import {
  318. submit,
  319. delItem,
  320. getDeptLazyTree,
  321. getGoods,
  322. savePurchase,
  323. saveShipping,
  324. getPorts,
  325. getSpecification,
  326. saveSell
  327. } from "@/api/basicData/customerInquiry";
  328. import goodsOption from "./configuration/commodity.json";
  329. import { contrastObj, contrastList } from "@/util/contrastData";
  330. import { getToken } from "@/util/auth";
  331. import { getPurchasePrice } from "@/api/basicData/fees"
  332. export default {
  333. name: "detailsPage",
  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. watch: {
  547. $route(to, from) {
  548. if (this.detailData.id) {
  549. } else {
  550. this.form = {};
  551. }
  552. }
  553. },
  554. methods: {
  555. queryData(id) {
  556. this.openFullScreen(false, "正在努力的加载...");
  557. detail(id)
  558. .then(res => {
  559. this.form = res.data.data;
  560. if (this.form.corpNameList) {
  561. this.configuration.dicData = this.form.corpNameList;
  562. }
  563. this.form.corps = this.form.corps.split(",");
  564. // if (res.data.data.specialItemList) this.contactsData = res.data.data.specialItemList
  565. if (res.data.data.presentItemList)
  566. this.contactsDataBuyFree = res.data.data.presentItemList;
  567. this.oldForm = Object.assign({}, this.form);
  568. // this.oldSpecialOffer = this.deepClone(this.contactsData)
  569. this.oldBuyFree = this.deepClone(this.contactsDataBuyFree);
  570. delete this.form.specialItemList;
  571. delete this.form.presentItemList;
  572. this.getItemdetail();
  573. })
  574. .finally(() => {
  575. this.openFullScreen(true);
  576. });
  577. },
  578. getItemdetail() {
  579. this.contactLoading = true;
  580. getItemdetail({
  581. current: this.contactPage.currentPage,
  582. size: this.contactPage.pageSize,
  583. pid: this.form.id
  584. })
  585. .then(res => {
  586. this.contactsData = res.data.data.records;
  587. this.contactPage.total = res.data.data.total;
  588. this.customerContact.height = window.innerHeight - 240;
  589. })
  590. .finally(() => {
  591. this.contactLoading = false;
  592. });
  593. },
  594. currentChange(val) {
  595. this.contactPage.currentPage = val;
  596. this.getItemdetail();
  597. },
  598. sizeChange(val) {
  599. this.contactPage.currentPage = 1;
  600. this.contactPage.pageSize = val;
  601. this.getItemdetail();
  602. },
  603. rePick(row, index, type) {
  604. this.reData = {
  605. ...row,
  606. index: index
  607. };
  608. if (type == 1) {
  609. this.newSpecial();
  610. } else {
  611. this.newBuyFree();
  612. }
  613. },
  614. // 新增特价弹窗
  615. newSpecial() {
  616. this.salesType = 1;
  617. this.dialogVisible = !this.dialogVisible;
  618. },
  619. // 买赠弹窗
  620. newBuyFree() {
  621. this.salesType = 2;
  622. this.dialogVisible = !this.dialogVisible;
  623. },
  624. closeGoods() {
  625. this.selectionList = [];
  626. this.treeDeptId = "";
  627. this.reData = null;
  628. },
  629. nodeClick(data) {
  630. this.treeDeptId = data.id;
  631. this.page.currentPage = 1;
  632. this.onLoad(this.page);
  633. },
  634. selectionChange(list) {
  635. this.selectionList = list;
  636. },
  637. rowClick(row) {
  638. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  639. },
  640. goodsSearch(params, done) {
  641. this.onLoad(this.page, params);
  642. done();
  643. },
  644. //商品查询
  645. onLoad(page, params = {}) {
  646. this.loading = true;
  647. getGoods(page.currentPage, page.pageSize, this.treeDeptId, params)
  648. .then(res => {
  649. const data = res.data.data;
  650. this.page.total = data.total;
  651. this.goodsList = data.records;
  652. if (this.page.total) {
  653. this.goodsOption.height = window.innerHeight - 400;
  654. } else {
  655. this.goodsOption.height = window.innerHeight - 400;
  656. }
  657. })
  658. .finally(() => {
  659. this.loading = false;
  660. });
  661. },
  662. // 确认导入商品
  663. importGoods() {
  664. if (this.reData) {
  665. if (this.selectionList.length != 1) {
  666. return this.$message.error("重新选择的时候只能选择一条数据");
  667. } else {
  668. this.selectionList.forEach(e => {
  669. if (this.reData.salesType == 1) {
  670. this.contactsData.forEach(async (item, index) => {
  671. if (index == this.reData.index) {
  672. item.purchasePrice = await this.getPurchasePrice(e);
  673. item.itemId = e.id;
  674. item.code = e.code;
  675. item.cname = e.cname;
  676. item.brand = e.brand;
  677. item.productCategory = e.goodsTypeName;
  678. item.typeno = e.typeno;
  679. item.brandItem = e.brandItem;
  680. // item.purchasePrice = this.brand.purchasePrice
  681. // item.salesPrice = this.brand.salesPrice
  682. // item.specialOffer = this.brand.specialOffer
  683. // item.updateUserName = this.brand.updateUserName
  684. // item.updateTime = this.brand.updateTime
  685. // item.salesType = this.brand.salesType
  686. }
  687. });
  688. } else {
  689. this.contactsDataBuyFree.forEach(async (item, index) => {
  690. item.itemId = e.id;
  691. item.code = e.code;
  692. item.cname = e.cname;
  693. item.brand = e.brand;
  694. item.productCategory = e.goodsTypeName;
  695. item.typeno = e.typeno;
  696. item.brandItem = e.brandItem;
  697. // item.purchasePrice = this.brand.purchasePrice
  698. // item.salesPrice = this.brand.salesPrice
  699. // item.salesPrice = this.brand.purchaseAmount
  700. // item.updateUserName = this.brand.salesVolume
  701. // item.updateUserName = this.brand.updateUserName
  702. // item.updateTime = this.brand.updateTime
  703. // item.salesType = this.brand.salesType
  704. });
  705. }
  706. });
  707. }
  708. } else {
  709. if (this.salesType == 1) {
  710. this.selectionList.forEach(async item => {
  711. this.contactsData.push({
  712. purchasePrice: await this.getPurchasePrice(item),
  713. itemId: item.id,
  714. code: item.code,
  715. brand: item.brand,
  716. productCategory: item.goodsTypeName,
  717. typeno: item.typeno,
  718. brandItem: item.brandItem,
  719. corpId: item.corpId,
  720. corpName: item.corpName,
  721. salesPrice: "",
  722. specialOffer: "",
  723. updateUserName: "",
  724. updateTime: "",
  725. salesType: "1"
  726. });
  727. });
  728. } else if (this.salesType == 2) {
  729. this.selectionList.forEach(item => {
  730. this.contactsDataBuyFree.push({
  731. itemId: item.id,
  732. code: item.code,
  733. brand: item.brand,
  734. productCategory: item.goodsTypeName,
  735. typeno: item.typeno,
  736. brandItem: item.brandItem,
  737. corpName: item.corpName,
  738. purchasePrice: "",
  739. salesPrice: "",
  740. purchaseAmount: "",
  741. salesVolume: "",
  742. updateUserName: "",
  743. updateTime: "",
  744. salesType: "2"
  745. });
  746. });
  747. }
  748. }
  749. this.dialogVisible = false;
  750. console.log(this.contactsData);
  751. },
  752. //买赠列表信息保存触发
  753. rowSaveBuyFree(row, done, loading) {
  754. console.log(row);
  755. console.log(this.contactsData);
  756. // this.contactsData.push(row)
  757. done();
  758. },
  759. //买赠列表点击行可编辑
  760. handleRowClickBuyFree(row, event, column) {
  761. console.log(row.$index);
  762. },
  763. //买赠列表修改信息触发
  764. rowUpdateBuyFree(row, index, done, loading) {
  765. done(row);
  766. },
  767. //买赠列表删除信息触发
  768. rowDelBuyFree(row, index, donerowDel) {
  769. this.$confirm("确定将选择数据删除?", {
  770. confirmButtonText: "确定",
  771. cancelButtonText: "取消",
  772. type: "warning"
  773. }).then(() => {
  774. //商品判断是否需要调用删除接口
  775. if (row.id) {
  776. corpsattn(row.id).then(res => {
  777. this.$message({
  778. type: "success",
  779. message: "操作成功!"
  780. });
  781. this.contactsDataBuyFree.splice(index, 1);
  782. });
  783. } else {
  784. this.$message({
  785. type: "success",
  786. message: "操作成功!"
  787. });
  788. this.contactsDataBuyFree.splice(index, 1);
  789. }
  790. });
  791. },
  792. //新增商品信息保存触发
  793. rowSave(row, done, loading) {
  794. console.log(row);
  795. console.log(this.contactsData);
  796. // this.contactsData.push(row)
  797. done();
  798. },
  799. //点击行可编辑
  800. handleRowClick(row, event, column) {
  801. console.log(row.$index);
  802. },
  803. //商品编辑
  804. rowCell(row, index) {
  805. if (row.$cellEdit && this.form.id) {
  806. itemSubmit({...row,pid: this.form.id}).then(res => {
  807. this.$message.success('保存成功')
  808. this.$refs.crudContact.rowCell(row, index);
  809. })
  810. } else {
  811. this.$refs.crudContact.rowCell(row, index);
  812. }
  813. },
  814. //买赠编辑
  815. rowCellE(row, index) {
  816. console.log(row);
  817. this.$refs.crudContactE.rowCell(row, index);
  818. },
  819. //修改商品信息触发
  820. rowUpdate(row, index, done, loading) {
  821. done(row);
  822. },
  823. //删除商品信息触发
  824. rowDel(row, index, donerowDel) {
  825. this.$confirm("确定将选择数据删除?", {
  826. confirmButtonText: "确定",
  827. cancelButtonText: "取消",
  828. type: "warning"
  829. }).then(() => {
  830. //商品判断是否需要调用删除接口
  831. if (row.id) {
  832. corpsattn(row.id).then(res => {
  833. this.$message({
  834. type: "success",
  835. message: "操作成功!"
  836. });
  837. this.contactsData.splice(index, 1);
  838. });
  839. } else {
  840. this.$message({
  841. type: "success",
  842. message: "操作成功!"
  843. });
  844. this.contactsData.splice(index, 1);
  845. }
  846. });
  847. },
  848. //修改提交触发
  849. editCustomer() {
  850. this.$refs["form"].validate(valid => {
  851. if (valid) {
  852. this.form.corps = this.form.corps.join(",");
  853. this.form.specialItemList = this.contactsData;
  854. this.form.presentItemList = this.contactsDataBuyFree;
  855. this.openFullScreen(false, "正在努力的加载...");
  856. typeSave(this.form).then(res => {
  857. this.$message({
  858. type: "success",
  859. message: this.form.id ? "修改成功!" : "新增成功!"
  860. });
  861. // this.backToList()
  862. this.queryData(res.data.data.id);
  863. });
  864. } else {
  865. return false;
  866. }
  867. });
  868. },
  869. //返回列表
  870. backToList() {
  871. this.$emit("goBack");
  872. },
  873. async saveGoodsColumn() {
  874. // const inSave = await this.saveColumnData(
  875. // this.getColumnName(26),
  876. // this.goodsOption
  877. // );
  878. // if (inSave) {
  879. // this.$message.success("保存成功");
  880. // //关闭窗口
  881. // this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  882. // }
  883. },
  884. //遮罩层
  885. openFullScreen(res, text) {
  886. const loading = this.$loading({
  887. lock: true,
  888. text: text,
  889. spinner: "el-icon-loading",
  890. background: "rgba(0, 0, 0, 0.7)"
  891. });
  892. if (res === true) loading.close();
  893. },
  894. getcorpId(row) {
  895. this.contactsData[row.index].corpId = row.id;
  896. },
  897. getcorpFeesId(row) {
  898. this.contactsDataBuyFree[row.index].corpId = row.id;
  899. },
  900. // 下载模板
  901. downloadHandle() {
  902. this.$confirm("是否下载模板文件?", "提示", {
  903. confirmButtonText: "确定",
  904. cancelButtonText: "取消",
  905. type: "warning"
  906. })
  907. .then(() => {
  908. window.open(
  909. `/api/blade-mocha-item/salespolicy/export-sales-policy?${
  910. this.website.tokenHeader
  911. }=${getToken()}`
  912. );
  913. })
  914. .catch(() => {
  915. this.$message({
  916. type: "info",
  917. message: "已取消"
  918. });
  919. });
  920. },
  921. //文件上传时
  922. uploading(event, file, fileList) {
  923. this.openFullScreen(false, "文件正在解析中");
  924. },
  925. importTemplate(res, file) {
  926. this.openFullScreen(true);
  927. let contactsData = [];
  928. contactsData = res.data;
  929. this.contactsData = this.contactsData.concat(contactsData);
  930. // console.log(res.data)
  931. },
  932. uploadError(err, file, fileList) {
  933. this.openFullScreen(true);
  934. this.$message.error(JSON.parse(err.message).msg);
  935. },
  936. getCorpList(data) {
  937. let arr = [];
  938. data.map(e => {
  939. arr.push(e.id);
  940. });
  941. this.form.corps = arr;
  942. },
  943. async getPurchasePrice(row) {
  944. let data;
  945. await getPurchasePrice({code: row.code}).then(res => {
  946. data = res.data.data.length > 0? res.data.data[0].purchasePrice: 0
  947. })
  948. return data;
  949. },
  950. }
  951. };
  952. </script>
  953. <style lang="scss" scoped>
  954. .back-icon {
  955. line-height: 64px;
  956. font-size: 20px;
  957. margin-right: 8px;
  958. }
  959. ::v-deep .el-form-item {
  960. margin-bottom: 0;
  961. }
  962. .el-dialogDeep {
  963. ::v-deep .el-dialog {
  964. margin: 1vh auto 0 !important;
  965. padding-bottom: 10px !important;
  966. .el-dialog__body,
  967. .el-dialog__footer {
  968. padding-bottom: 0 !important;
  969. padding-top: 0 !important;
  970. }
  971. }
  972. }
  973. ::v-deep .el-form-item {
  974. margin-bottom: 0;
  975. }
  976. ::v-deep .el-form-item__content {
  977. line-height: 32px;
  978. }
  979. </style>