AddPolicy.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. <template>
  2. <div>
  3. <div v-show="isCondition == 0">
  4. <el-header height="50px" class="header">
  5. <el-page-header
  6. content="新增"
  7. @back="($parent.isShow = 1), ($parent.isFlag = '')"
  8. />
  9. </el-header>
  10. <div class="app-container">
  11. <div class="screen-container">
  12. <h4>销售政策信息</h4>
  13. <el-divider />
  14. <el-form
  15. ref="form"
  16. :model="searchForm"
  17. label-width="120px"
  18. size="small"
  19. class="demo-searchForm"
  20. >
  21. <el-row>
  22. <el-col :xs="24" :ms="12" :lg="12">
  23. <el-form-item label="销售政策编号">
  24. <el-input
  25. v-model="searchForm.code"
  26. disabled
  27. placeholder="如未填写,则系统自动生成"
  28. />
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :ms="12" :lg="12">
  32. <el-form-item label="销售政策名称" prop="title">
  33. <el-input
  34. v-model="searchForm.title"
  35. placeholder="销售政策名称"
  36. />
  37. </el-form-item>
  38. </el-col>
  39. <el-col :xs="24" :ms="12" :lg="12">
  40. <el-form-item label="销售政策类型" prop="type">
  41. <el-select
  42. v-model="searchForm.type"
  43. size="small"
  44. placeholder="销售政策类型"
  45. class="select_height"
  46. >
  47. <el-option
  48. v-for="(item, index) in typeOptions"
  49. :key="index"
  50. :label="item.label"
  51. :value="item.value"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. </el-col>
  56. <!-- <el-col :xs="24" :ms="12" :lg="12">
  57. <el-form-item label="产品品类" prop="mainId">
  58. <el-select
  59. v-model="searchForm.mainId"
  60. :disabled="dataList.length ? true : false"
  61. placeholder="请选择"
  62. @change="handelStop"
  63. >
  64. <el-option
  65. v-for="item in dictList"
  66. :label="item.dictValue"
  67. :value="item.dictCode"
  68. ></el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col> -->
  72. <el-col :xs="24" :ms="12" :lg="12">
  73. <el-form-item label="生效日期" prop="startTime">
  74. <el-date-picker
  75. v-model="searchForm.startTime"
  76. type="datetime"
  77. placeholder="生效日期"
  78. default-time="00:00:00"
  79. value-format="yyyy-MM-dd HH:mm:ss"
  80. /> </el-form-item></el-col>
  81. <el-col :xs="24" :ms="12" :lg="12">
  82. <el-form-item label="失效日期" prop="endTime">
  83. <el-date-picker
  84. v-model="searchForm.endTime"
  85. type="datetime"
  86. placeholder="失效日期"
  87. default-time="00:00:00"
  88. value-format="yyyy-MM-dd HH:mm:ss"
  89. /> </el-form-item></el-col>
  90. <el-col :xs="24" :ms="24" :lg="24">
  91. <el-form-item label="销售政策说明" prop="remark">
  92. <el-input
  93. v-model="searchForm.remark"
  94. placeholder="新风机变频挂机。按提货数量1:3开单"
  95. />
  96. </el-form-item>
  97. </el-col>
  98. <el-col :xs="24" :ms="24" :lg="24">
  99. <el-form-item label="政策封面图">
  100. <ImageUpload :file-list="fileList" :multiple="false" />
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. </el-form>
  105. </div>
  106. <div class="mymian-container">
  107. <el-row>
  108. <el-divider />
  109. <el-row type="flex">
  110. <el-col :span="12">
  111. <h4 style="display: inline-block; margin-right: 20px">
  112. 货品信息
  113. </h4>
  114. <template>
  115. <el-upload
  116. class="import-btn"
  117. :action="baseURL + 'student/import'"
  118. :http-request="handleImport"
  119. :file-list="importFileList"
  120. :show-file-list="false"
  121. >
  122. <el-button
  123. type="primary"
  124. size="small"
  125. >导入货品价格表</el-button>
  126. </el-upload>
  127. </template>
  128. <el-button
  129. type="primary"
  130. size="small"
  131. @click="hanleDownloadFiles"
  132. >下载模板</el-button>
  133. </el-col>
  134. </el-row>
  135. <el-divider />
  136. </el-row>
  137. <el-table
  138. v-loading="listLoading"
  139. :data="dataList"
  140. element-loading-text="Loading"
  141. max-height="600"
  142. border
  143. fit
  144. highlight-current-row
  145. stripe
  146. >
  147. <el-table-column
  148. type="index"
  149. label="序号"
  150. width="50"
  151. align="center"
  152. />
  153. <el-table-column
  154. prop="materialNumber"
  155. label="货品编码"
  156. align="center"
  157. >
  158. <template slot-scope="scope">
  159. <el-select
  160. v-model="scope.row.materialNumber"
  161. v-el-select-loadmore="loadmore"
  162. size="small"
  163. :remote-method="(query)=>remoteMethod(query,'number')"
  164. filterable
  165. remote
  166. @change="handleK3List($event, scope.row)"
  167. >
  168. <el-option
  169. v-for="item in k3List"
  170. :key="item.id"
  171. :label="item.number"
  172. :value="item.id"
  173. />
  174. </el-select>
  175. </template>
  176. </el-table-column>
  177. <el-table-column
  178. prop="materialName"
  179. label="货品名称"
  180. align="center"
  181. />
  182. <el-table-column
  183. prop="specification"
  184. label="规格型号"
  185. align="center"
  186. >
  187. <template slot-scope="scope">
  188. <el-select
  189. v-model="scope.row.specification"
  190. size="small"
  191. :remote-method="(query)=>remoteMethod(query,'specification')"
  192. filterable
  193. remote
  194. @change="handleK3List($event, scope.row)"
  195. >
  196. <el-option
  197. v-for="item in k3List"
  198. :key="item.id"
  199. :label="item.specification"
  200. :value="item.id"
  201. />
  202. </el-select>
  203. </template>
  204. </el-table-column>
  205. <el-table-column
  206. prop="saleTypeName"
  207. label="销售类型"
  208. align="center"
  209. >
  210. <template slot-scope="scope">
  211. <el-select
  212. v-model="scope.row.saleTypeId"
  213. size="small"
  214. filterable
  215. @change="handleSalesType($event, scope.row)"
  216. >
  217. <el-option
  218. v-for="item in typeList"
  219. :key="item.id"
  220. :label="item.saleName"
  221. :value="item.id"
  222. />
  223. </el-select>
  224. </template>
  225. </el-table-column>
  226. <el-table-column
  227. prop="saleTypeCode"
  228. label="销售类型编码"
  229. align="center"
  230. />
  231. <el-table-column prop="discAmount" label="格力折扣" align="center">
  232. <template slot-scope="scope">
  233. <el-input
  234. v-model.number="scope.row.discAmount"
  235. type="number"
  236. placeholder="请输入格力折扣"
  237. size="small"
  238. />
  239. </template>
  240. </el-table-column>
  241. <el-table-column prop="price" label="单价" align="center">
  242. <template slot-scope="scope">
  243. <el-input
  244. v-model.number="scope.row.price"
  245. type="number"
  246. placeholder="请输入单价"
  247. size="small"
  248. />
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="支付钱包" align="center">
  252. <template slot-scope="scope">
  253. <el-select
  254. v-model="scope.row.walletIds"
  255. size="small"
  256. multiple
  257. filterable
  258. >
  259. <el-option
  260. v-for="item in NoRebateWalletList"
  261. :key="item.id"
  262. :label="item.name"
  263. :value="item.id"
  264. />
  265. </el-select>
  266. <!-- <el-tag
  267. style="margin: 5px"
  268. type="success"
  269. size="small"
  270. v-for="item in scope.row.walletRelaList"
  271. >{{ item.walletName }}</el-tag
  272. > -->
  273. </template>
  274. </el-table-column>
  275. <el-table-column prop="remark" label="备注" align="center">
  276. <template slot-scope="scope">
  277. <el-input
  278. v-model="scope.row.remark"
  279. placeholder="备注"
  280. size="small"
  281. />
  282. </template>
  283. </el-table-column>
  284. <el-table-column fixed="right" label="操作" align="center">
  285. <template slot-scope="scope">
  286. <el-popconfirm
  287. confirm-button-text="好的"
  288. cancel-button-text="不用了"
  289. icon="el-icon-info"
  290. icon-color="red"
  291. title="内容确定删除吗?"
  292. @onConfirm="hanleDelete(scope.row.id, scope.$index)"
  293. >
  294. <el-button
  295. slot="reference"
  296. type="text"
  297. class="textColor el-popover-left"
  298. >删除</el-button>
  299. </el-popconfirm>
  300. </template>
  301. </el-table-column>
  302. </el-table>
  303. <!-- 分页 -->
  304. <div
  305. style="
  306. margin: 20px 20px 20px 0;
  307. display: flex;
  308. justify-content: space-between;
  309. "
  310. >
  311. <div>
  312. <el-button
  313. type="primary"
  314. size="small"
  315. @click="handleNewInfo"
  316. >添加</el-button>
  317. <el-button
  318. type="primary"
  319. size="small"
  320. @click="handleSave"
  321. >保存</el-button>
  322. </div>
  323. <!-- <el-pagination-->
  324. <!-- :current-page="dcurrentPage"-->
  325. <!-- :page-sizes="pageSizeArr"-->
  326. <!-- :page-size="size"-->
  327. <!-- layout="total, sizes, prev, pager, next, jumper"-->
  328. <!-- :total="listTotal"-->
  329. <!-- @size-change="handleSizeChange2"-->
  330. <!-- @current-change="handleCurrentChange2"-->
  331. <!-- />-->
  332. </div>
  333. <el-row>
  334. <el-divider />
  335. <el-row type="flex">
  336. <el-col :span="12">
  337. <h4 style="display: inline-block; margin-right: 20px">
  338. 条件信息
  339. </h4>
  340. <el-button
  341. type="primary"
  342. size="small"
  343. @click="isCondition = 1"
  344. >添加</el-button></el-col>
  345. </el-row>
  346. <el-divider />
  347. </el-row>
  348. <el-table
  349. :data="conditionList"
  350. element-loading-text="Loading"
  351. border
  352. fit
  353. highlight-current-row
  354. stripe
  355. >
  356. <el-table-column
  357. fixed
  358. type="index"
  359. label="序号"
  360. width="50"
  361. align="center"
  362. />
  363. <el-table-column prop="name" label="限定条件" align="center">
  364. <template slot-scope="scope">
  365. <el-input
  366. v-model="scope.row.name"
  367. style="text-align: center"
  368. placeholder="请输入名称"
  369. :disabled="scope.row.fang"
  370. @blur="handleConditionName(scope.row)"
  371. />
  372. </template>
  373. </el-table-column>
  374. <el-table-column
  375. fixed="right"
  376. width="150"
  377. label="操作"
  378. align="center"
  379. >
  380. <template slot-scope="scope">
  381. <el-button
  382. type="text"
  383. size="small"
  384. @click="scope.row.fang = false"
  385. >编辑</el-button>
  386. <el-button
  387. type="text"
  388. size="small"
  389. @click="handleCondition(scope.row.id, scope.$index)"
  390. >删除</el-button>
  391. </template>
  392. </el-table-column>
  393. </el-table>
  394. </div>
  395. <div>
  396. <el-row>
  397. <el-divider />
  398. <el-row type="flex" align="middle">
  399. <el-col :span="2">
  400. <h4>经销商信息</h4>
  401. </el-col>
  402. </el-row>
  403. <el-divider />
  404. </el-row>
  405. <Transfer @handleAddPolicy="handleAddPolicy" @handleReset="handleReset" />
  406. </div>
  407. </div>
  408. </div>
  409. <AddCondition
  410. v-show="isCondition == 1"
  411. @handleSubmitCon="handleSubmitCon"
  412. />
  413. </div>
  414. </template>
  415. <script>
  416. import { mapGetters, mapMutations } from 'vuex'
  417. import Minxin from '@/mixin'
  418. import {
  419. addPoliy,
  420. deleteCondition,
  421. deleteMaterialPolicy,
  422. getConditionList,
  423. getK3List,
  424. getMaterialList,
  425. getNoRebateWalletList,
  426. getTypeList,
  427. savePolicy,
  428. updateCondition
  429. } from '@/api/policy_list'
  430. import { downloadFiles, handleImport } from '@/utils/util'
  431. import Transfer from './Transfer'
  432. import AddCondition from './AddCondition'
  433. import ImageUpload from '@/components/Common/image-upload.vue'
  434. export default {
  435. directives: {
  436. 'el-select-loadmore': {
  437. bind(el, binding) {
  438. // 获取element-ui定义好的scroll盒⼦
  439. const SELECTWRAP_DOM = el.querySelector(
  440. '.el-select-dropdown .el-select-dropdown__wrap'
  441. )
  442. SELECTWRAP_DOM.addEventListener('scroll', function() {
  443. /**
  444. * scrollHeight 获取元素内容⾼度(只读)
  445. * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
  446. * clientHeight 读取元素的可见⾼度(只读)
  447. * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
  448. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  449. */
  450. const condition =
  451. this.scrollHeight - this.scrollTop <= this.clientHeight
  452. if (condition) {
  453. binding.value()
  454. }
  455. })
  456. }
  457. }
  458. },
  459. mixins: [Minxin],
  460. data() {
  461. return {
  462. fang: false,
  463. input: '',
  464. baseURL: '',
  465. isCondition: 0,
  466. searchForm: {
  467. code: '',
  468. endTime: '',
  469. imgSrc: '',
  470. remark: '',
  471. startTime: '',
  472. title: '',
  473. mainId: '',
  474. mainName: '',
  475. type: ''
  476. },
  477. dataList: [],
  478. addList: [],
  479. pageSizeArr: [10, 20, 30, 50],
  480. size: 10,
  481. listLoading: false,
  482. dialogVisible: false,
  483. importFileList: [],
  484. fileList: [],
  485. options: {},
  486. value: '',
  487. typeList: [],
  488. walletList: [],
  489. typeOptions: [
  490. {
  491. value: 'PROVISION',
  492. label: '配提'
  493. },
  494. {
  495. value: 'LIMIT',
  496. label: '限量'
  497. }
  498. ],
  499. conditionList: [],
  500. dictList: [],
  501. k3List: [],
  502. NoRebateWalletList: [],
  503. sleectBox: { currentPage: 1 },
  504. dpageSize: 10,
  505. dcurrentPage: 1
  506. }
  507. },
  508. computed: {
  509. ...mapGetters({
  510. comCode: 'code'
  511. })
  512. },
  513. mounted() {
  514. this.searchForm.code = this.comCode
  515. },
  516. updated() {
  517. this.searchForm.code = this.comCode
  518. },
  519. created() {
  520. this.getCommonApi()
  521. // console.log(this.$store.code);
  522. if (this.$parent.isFlag) {
  523. // this.handletwoList()
  524. }
  525. },
  526. methods: {
  527. ...mapMutations('sales', ['initData']),
  528. // 下载excel模板
  529. hanleDownloadFiles() {
  530. downloadFiles('/policy/download')
  531. },
  532. handleCondition(id, index) {
  533. deleteCondition({ id }).then((res) => {
  534. this.conditionList.splice(index, 1)
  535. Object.assign(
  536. this.$children[9].$data,
  537. this.$children[9].$options.data()
  538. )
  539. this.$successMsg('删除成功')
  540. })
  541. },
  542. loadmore() {
  543. this.sleectBox.currentPage++
  544. this.getK3List()
  545. },
  546. getK3List() {
  547. getK3List({
  548. pageNum: this.sleectBox.currentPage,
  549. pageSize: 10,
  550. keyword: ''
  551. }).then((res) => {
  552. this.k3List = [...this.k3List, ...res.data.records]
  553. })
  554. },
  555. remoteMethod(query, type) {
  556. console.log(query, type)
  557. if (query !== '') {
  558. getK3List({
  559. pageNum: 1,
  560. pageSize: 100,
  561. keyword: '',
  562. number: type === 'number' ? query : '',
  563. oldNumber: '',
  564. specification: type === 'specification' ? query : ''
  565. }).then((res) => {
  566. this.k3List = res.data.records
  567. })
  568. } else {
  569. this.sleectBox.currentPage = 1
  570. this.getK3List()
  571. }
  572. },
  573. getCommonApi() {
  574. this.getK3List()
  575. // 非返利钱包
  576. getNoRebateWalletList({ walletName: '' }).then((res) => {
  577. this.NoRebateWalletList = res.data
  578. console.log(this.NoRebateWalletList, 'kkkk')
  579. })
  580. const params = {
  581. pageNum: 1,
  582. pageSize: -1,
  583. saleCode: '',
  584. saleName: '',
  585. status: ''
  586. }
  587. // 获取销售类型列表
  588. getTypeList(params).then((res) => {
  589. this.typeList = res.data.records
  590. })
  591. // this.handletwoList()
  592. // const params = {
  593. // pageNum: 1,
  594. // pageSize: 10,
  595. // saleCode: "",
  596. // saleName: "",
  597. // status: "",
  598. // };
  599. // const walletParams = {
  600. // pageNum: 1,
  601. // pageSize: 10,
  602. // mainName: "",
  603. // saleTypeCode: "",
  604. // saleTypeName: "",
  605. // status: "",
  606. // };
  607. // // 获取钱包列表
  608. // getWalletList(walletParams).then((res) => {
  609. // this.walletList = res.data.records;
  610. // });
  611. // getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  612. // this.dictList = res.data;
  613. // });
  614. },
  615. handleSalesType(e, row) {
  616. const item = this.typeList.filter((k) => {
  617. return k.id == e
  618. })[0]
  619. this.$set(row, 'saleTypeCode', item.saleCode)
  620. this.$set(row, 'saleTypeName', item.saleName)
  621. // this.$set(row,'saleTypeId',item.id)
  622. },
  623. // 修改条件名称
  624. handleConditionName(row) {
  625. console.log(row.name)
  626. updateCondition({ id: row.id, name: row.name }).then((res) => {
  627. this.$successMsg('修改成功')
  628. row.fang = true
  629. })
  630. },
  631. // 提交信息
  632. handleSubmitCon() {
  633. const params = {
  634. policyId: this.comCode
  635. }
  636. // 获取条件政策
  637. getConditionList(params).then((res) => {
  638. for (let i = 0; i < res.data.length; i++) {
  639. res.data[i].fang = true
  640. }
  641. this.conditionList = res.data
  642. })
  643. },
  644. // 视图部分已注释,废弃的功能 fucn
  645. handelStop() {
  646. if (this.searchForm.mainId) {
  647. this.fang = true
  648. } else {
  649. this.$errorMsg('请选择产品品类')
  650. }
  651. },
  652. // 导入
  653. async handleImport(param) {
  654. this.importLoading = true
  655. const file = param.file
  656. console.log(file, 123)
  657. const formData = new FormData()
  658. formData.append('file', file)
  659. formData.append('policyId', this.searchForm.code)
  660. // formData.append("mainId", this.searchForm.mainId);
  661. const result = await handleImport('/policy/material/import', formData)
  662. this.importLoading = false
  663. this.importFileList = []
  664. if (result.code == 200) {
  665. this.$alert(result.message, '导入成功', {
  666. confirmButtonText: '确定'
  667. })
  668. this.dataList = []
  669. this.listTotal = 0
  670. this.sleectBox.currentPage = 1
  671. this.handletwoList()
  672. } else {
  673. this.$alert(result.message, '导入失败', {
  674. confirmButtonText: '确定'
  675. })
  676. }
  677. },
  678. getList() {
  679. if (this.$parent.isFlag) {
  680. this.handletwoList()
  681. }
  682. },
  683. // 更改每页数量
  684. handleSizeChange1(val) {
  685. this.pageSize = val
  686. this.currentPage = 1
  687. this.handletwoList()
  688. },
  689. // 更改当前页
  690. handleCurrentChange1(val) {
  691. this.currentPage = val
  692. this.handletwoList()
  693. },
  694. // 更改每页数量
  695. handleSizeChange2(val) {
  696. this.dpageSize = val
  697. this.dcurrentPage = 1
  698. this.handletwoList()
  699. },
  700. // 更改当前页
  701. handleCurrentChange2(val) {
  702. this.dcurrentPage = val
  703. this.handletwoList()
  704. },
  705. // 获取货品信息
  706. handletwoList() {
  707. // this.searchForm.type
  708. this.listLoading = true
  709. const paramss = {
  710. pageNum: this.dcurrentPage,
  711. pageSize: this.dpageSize,
  712. policyId: this.comCode,
  713. saleTypeCode: ''
  714. }
  715. getMaterialList(paramss)
  716. .then((result) => {
  717. result.data.records.forEach((k) => {
  718. k.walletIds = []
  719. if (!k.specification) {
  720. k.materialNumber = k.materialId
  721. k.specification = k.materialId
  722. } else {
  723. k.materialNumber = k.materialNumber
  724. k.specification = k.specification
  725. }
  726. k.materialId = k.materialId
  727. k.walletRelaList.forEach((l) => {
  728. l.id = l.walletId
  729. l.name = l.walletName
  730. k.walletIds = [...k.walletIds, l.walletId]
  731. })
  732. })
  733. // this.dataList=[]
  734. this.dataList = result.data.records
  735. this.listTotal = result.data.total
  736. this.listLoading = false
  737. })
  738. .catch((err) => {
  739. console.error(err)
  740. })
  741. },
  742. // 提交审核
  743. handleAddPolicy(policyCustomers) {
  744. if (!this.searchForm.title) {
  745. this.$errorMsg('请输入说明')
  746. return
  747. }
  748. if (!this.searchForm.type) {
  749. this.$errorMsg('请选择类型')
  750. return
  751. }
  752. if (!this.searchForm.startTime) {
  753. this.$errorMsg('请选择生效日期')
  754. return
  755. }
  756. if (policyCustomers.length) {
  757. var arr = []
  758. policyCustomers.forEach((el) => {
  759. arr.push({
  760. customerId: el.id,
  761. customerName: el.name,
  762. customerNumber: el.number,
  763. lastOrderTime: '',
  764. limitTakeNum: 0,
  765. policyId: this.comCode,
  766. policyTitle: '',
  767. remark: ''
  768. })
  769. })
  770. // this.dictList.forEach((k) => {
  771. // if (k.dictCode == this.searchForm.mainId) {
  772. // this.searchForm.mainName = k.dictValue;
  773. // }
  774. // });
  775. const params = {
  776. adminCompanyId: '',
  777. code: '',
  778. customerCount: 0,
  779. examineBy: '',
  780. examineRemark: '',
  781. examineStatus: '',
  782. id: '',
  783. policyCustomers: arr,
  784. remark: '',
  785. status: true,
  786. title: '',
  787. type: '',
  788. ...this.searchForm,
  789. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  790. imgSrc: this.fileList.length ? this.fileList[0].url : ''
  791. }
  792. console.log(this.fileList)
  793. addPoliy(params).then((res) => {
  794. console.log(res)
  795. this.$successMsg('新增成功')
  796. this.$parent.getList()
  797. this.$parent.isShow = 1
  798. })
  799. } else {
  800. this.$errorMsg('选择经销商 ')
  801. }
  802. },
  803. // 删除
  804. hanleDelete(id, index) {
  805. if (id) {
  806. const params = { policyMaterialId: id }
  807. deleteMaterialPolicy(params).then((res) => {
  808. this.dataList.splice(index, 1)
  809. })
  810. return
  811. }
  812. this.dataList.splice(index, 1)
  813. // this.listTotal -= 1;
  814. this.$successMsg('删除成功')
  815. },
  816. handleNewInfo() {
  817. // 物料列表
  818. this.dataList.push({
  819. id: '',
  820. discAmount: 0,
  821. materialId: '',
  822. materialName: '',
  823. materialNumber: '',
  824. policyId: this.comCode,
  825. price: '',
  826. remark: '',
  827. saleTypeCode: '',
  828. saleTypeId: '',
  829. saleTypeName: '',
  830. specification: '',
  831. walletIds: [this.NoRebateWalletList[0].id],
  832. walletRelaList: []
  833. })
  834. this.sleectBox.currentPage = 1
  835. // this.listTotal += 1;
  836. // this.dataList.push(this.addList[this.addList.length-1])
  837. },
  838. handleSave() {
  839. if (!this.dataList.length) {
  840. return
  841. }
  842. for (let i = 0; i < this.dataList.length; i++) {
  843. if (!this.dataList[i].materialId) {
  844. this.$errorMsg('请选择货品')
  845. return
  846. }
  847. if (!this.dataList[i].saleTypeId) {
  848. this.$errorMsg('请选择销售类型')
  849. return
  850. }
  851. if (!this.dataList[i].price) {
  852. this.$errorMsg('请输入单价')
  853. return
  854. }
  855. if (!this.dataList[i].walletIds.length) {
  856. this.$errorMsg('请选择钱包')
  857. return
  858. }
  859. }
  860. savePolicy(this.dataList).then((res) => {
  861. this.dataList = []
  862. this.sleectBox.currentPage = 1
  863. this.$successMsg('保存成功')
  864. this.handletwoList()
  865. })
  866. },
  867. handleK3List(e, row) {
  868. const item = this.k3List.filter((k) => {
  869. return k.id == e
  870. })[0]
  871. this.$set(row,'materialNumber',item.number)
  872. this.$set(row, 'materialName', item.name)
  873. this.$set(row, 'specification', item.specification)
  874. this.$set(row, 'materialId', item.id)
  875. this.getK3List()
  876. },
  877. handleReset() {
  878. Object.assign(this.$data, this.$options.data())
  879. }
  880. },
  881. components: {
  882. Transfer,
  883. AddCondition,
  884. ImageUpload
  885. }
  886. }
  887. </script>
  888. <style lang="scss" scoped>
  889. h4 {
  890. margin: 0;
  891. }
  892. .pdt {
  893. padding-top: 20px;
  894. }
  895. .import-btn {
  896. margin-right: 10px;
  897. display: inline-block;
  898. }
  899. .radio {
  900. padding: 20px 0;
  901. }
  902. .el-divider--horizontal {
  903. margin: 20px 0;
  904. }
  905. .el-container .el-divider--horizontal {
  906. margin: 10px;
  907. }
  908. .el-select {
  909. width: 100%;
  910. }
  911. .footer {
  912. margin-bottom: 20px;
  913. }
  914. </style>