AddPolicy.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  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. border
  142. fit
  143. highlight-current-row
  144. stripe
  145. >
  146. <el-table-column
  147. type="index"
  148. label="序号"
  149. width="50"
  150. align="center"
  151. />
  152. <el-table-column
  153. prop="materialNumber"
  154. label="货品编码"
  155. align="center"
  156. >
  157. <template slot-scope="scope">
  158. <el-select
  159. v-model="scope.row.materialNumber"
  160. v-el-select-loadmore="loadmore"
  161. size="small"
  162. :remote-method="(query)=>remoteMethod(query,'number')"
  163. filterable
  164. remote
  165. @change="handleK3List($event, scope.row)"
  166. >
  167. <el-option
  168. v-for="item in k3List"
  169. :key="item.id"
  170. :label="item.number"
  171. :value="item.id"
  172. />
  173. </el-select>
  174. </template>
  175. </el-table-column>
  176. <el-table-column
  177. prop="materialName"
  178. label="货品名称"
  179. align="center"
  180. />
  181. <el-table-column
  182. prop="specification"
  183. label="规格型号"
  184. align="center"
  185. >
  186. <template slot-scope="scope">
  187. <el-select
  188. v-model="scope.row.specification"
  189. size="small"
  190. :remote-method="(query)=>remoteMethod(query,'specification')"
  191. filterable
  192. remote
  193. @change="handleK3List($event, scope.row)"
  194. >
  195. <el-option
  196. v-for="item in k3List"
  197. :key="item.id"
  198. :label="item.specification"
  199. :value="item.id"
  200. />
  201. </el-select>
  202. </template>
  203. </el-table-column>
  204. <el-table-column
  205. prop="saleTypeName"
  206. label="销售类型"
  207. align="center"
  208. >
  209. <template slot-scope="scope">
  210. <el-select
  211. v-model="scope.row.saleTypeId"
  212. size="small"
  213. filterable
  214. @change="handleSalesType($event, scope.row)"
  215. >
  216. <el-option
  217. v-for="item in typeList"
  218. :key="item.id"
  219. :label="item.saleName"
  220. :value="item.id"
  221. />
  222. </el-select>
  223. </template>
  224. </el-table-column>
  225. <el-table-column
  226. prop="saleTypeCode"
  227. label="销售类型编码"
  228. align="center"
  229. />
  230. <el-table-column prop="discAmount" label="格力折扣" align="center">
  231. <template slot-scope="scope">
  232. <el-input
  233. v-model.number="scope.row.discAmount"
  234. type="number"
  235. placeholder="请输入格力折扣"
  236. size="small"
  237. />
  238. </template>
  239. </el-table-column>
  240. <el-table-column prop="price" label="单价" align="center">
  241. <template slot-scope="scope">
  242. <el-input
  243. v-model.number="scope.row.price"
  244. type="number"
  245. placeholder="请输入单价"
  246. size="small"
  247. />
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="支付钱包" align="center">
  251. <template slot-scope="scope">
  252. <el-select
  253. v-model="scope.row.walletIds"
  254. size="small"
  255. multiple
  256. filterable
  257. >
  258. <el-option
  259. v-for="item in NoRebateWalletList"
  260. :key="item.id"
  261. :label="item.name"
  262. :value="item.id"
  263. />
  264. </el-select>
  265. <!-- <el-tag
  266. style="margin: 5px"
  267. type="success"
  268. size="small"
  269. v-for="item in scope.row.walletRelaList"
  270. >{{ item.walletName }}</el-tag
  271. > -->
  272. </template>
  273. </el-table-column>
  274. <el-table-column prop="remark" label="备注" align="center">
  275. <template slot-scope="scope">
  276. <el-input
  277. v-model="scope.row.remark"
  278. placeholder="备注"
  279. size="small"
  280. />
  281. </template>
  282. </el-table-column>
  283. <el-table-column fixed="right" label="操作" align="center">
  284. <template slot-scope="scope">
  285. <el-popconfirm
  286. confirm-button-text="好的"
  287. cancel-button-text="不用了"
  288. icon="el-icon-info"
  289. icon-color="red"
  290. title="内容确定删除吗?"
  291. @onConfirm="hanleDelete(scope.row.id, scope.$index)"
  292. >
  293. <el-button
  294. slot="reference"
  295. type="text"
  296. class="textColor el-popover-left"
  297. >删除</el-button>
  298. </el-popconfirm>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. <!-- 分页 -->
  303. <div
  304. style="
  305. margin: 20px 20px 20px 0;
  306. display: flex;
  307. justify-content: space-between;
  308. "
  309. >
  310. <div>
  311. <el-button
  312. type="primary"
  313. size="small"
  314. @click="handleNewInfo"
  315. >添加</el-button>
  316. <el-button
  317. type="primary"
  318. size="small"
  319. @click="handleSave"
  320. >保存</el-button>
  321. </div>
  322. <el-pagination
  323. :current-page="dcurrentPage"
  324. :page-sizes="pageSizeArr"
  325. :page-size="size"
  326. layout="total, sizes, prev, pager, next, jumper"
  327. :total="listTotal"
  328. @size-change="handleSizeChange2"
  329. @current-change="handleCurrentChange2"
  330. />
  331. </div>
  332. <el-row>
  333. <el-divider />
  334. <el-row type="flex">
  335. <el-col :span="12">
  336. <h4 style="display: inline-block; margin-right: 20px">
  337. 条件信息
  338. </h4>
  339. <el-button
  340. type="primary"
  341. size="small"
  342. @click="isCondition = 1"
  343. >添加</el-button></el-col>
  344. </el-row>
  345. <el-divider />
  346. </el-row>
  347. <el-table
  348. v-loading="listLoading"
  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: -1,
  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. const paramss = {
  709. pageNum: this.dcurrentPage,
  710. pageSize: this.dpageSize,
  711. policyId: this.comCode,
  712. saleTypeCode: ''
  713. }
  714. getMaterialList(paramss)
  715. .then((result) => {
  716. result.data.records.forEach((k) => {
  717. k.walletIds = []
  718. if (!k.specification) {
  719. k.materialNumber = k.materialId
  720. k.specification = k.materialId
  721. } else {
  722. k.materialNumber = k.materialNumber
  723. k.specification = k.specification
  724. }
  725. k.materialId = k.materialId
  726. k.walletRelaList.forEach((l) => {
  727. l.id = l.walletId
  728. l.name = l.walletName
  729. k.walletIds = [...k.walletIds, l.walletId]
  730. })
  731. })
  732. // this.dataList=[]
  733. this.dataList = result.data.records
  734. this.listTotal = result.data.total
  735. })
  736. .catch((err) => {
  737. console.error(err)
  738. })
  739. },
  740. // 提交审核
  741. handleAddPolicy(policyCustomers) {
  742. if (!this.searchForm.title) {
  743. this.$errorMsg('请输入说明')
  744. return
  745. }
  746. if (!this.searchForm.type) {
  747. this.$errorMsg('请选择类型')
  748. return
  749. }
  750. if (!this.searchForm.startTime) {
  751. this.$errorMsg('请选择生效日期')
  752. return
  753. }
  754. if (policyCustomers.length) {
  755. var arr = []
  756. policyCustomers.forEach((el) => {
  757. arr.push({
  758. customerId: el.id,
  759. customerName: el.name,
  760. customerNumber: el.number,
  761. lastOrderTime: '',
  762. limitTakeNum: 0,
  763. policyId: this.comCode,
  764. policyTitle: '',
  765. remark: ''
  766. })
  767. })
  768. // this.dictList.forEach((k) => {
  769. // if (k.dictCode == this.searchForm.mainId) {
  770. // this.searchForm.mainName = k.dictValue;
  771. // }
  772. // });
  773. const params = {
  774. adminCompanyId: '',
  775. code: '',
  776. customerCount: 0,
  777. examineBy: '',
  778. examineRemark: '',
  779. examineStatus: '',
  780. id: '',
  781. policyCustomers: arr,
  782. remark: '',
  783. status: true,
  784. title: '',
  785. type: '',
  786. ...this.searchForm,
  787. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  788. imgSrc: this.fileList.length ? this.fileList[0].url : ''
  789. }
  790. console.log(this.fileList)
  791. addPoliy(params).then((res) => {
  792. console.log(res)
  793. this.$successMsg('新增成功')
  794. this.$parent.getList()
  795. this.$parent.isShow = 1
  796. })
  797. } else {
  798. this.$errorMsg('选择经销商 ')
  799. }
  800. },
  801. // 删除
  802. hanleDelete(id, index) {
  803. if (id) {
  804. const params = { policyMaterialId: id }
  805. deleteMaterialPolicy(params).then((res) => {
  806. this.dataList.splice(index, 1)
  807. })
  808. return
  809. }
  810. this.dataList.splice(index, 1)
  811. // this.listTotal -= 1;
  812. this.$successMsg('删除成功')
  813. },
  814. handleNewInfo() {
  815. // 物料列表
  816. this.dataList.push({
  817. id: '',
  818. discAmount: '',
  819. materialId: '',
  820. materialName: '',
  821. materialNumber: '',
  822. policyId: this.comCode,
  823. price: '',
  824. remark: '',
  825. saleTypeCode: '',
  826. saleTypeId: '',
  827. saleTypeName: '',
  828. specification: '',
  829. walletIds: [this.NoRebateWalletList[0].id],
  830. walletRelaList: []
  831. })
  832. this.sleectBox.currentPage = 1
  833. // this.listTotal += 1;
  834. // this.dataList.push(this.addList[this.addList.length-1])
  835. },
  836. handleSave() {
  837. if (!this.dataList.length) {
  838. return
  839. }
  840. for (let i = 0; i < this.dataList.length; i++) {
  841. if (!this.dataList[i].materialId) {
  842. this.$errorMsg('请选择货品')
  843. return
  844. }
  845. if (!this.dataList[i].saleTypeId) {
  846. this.$errorMsg('请选择销售类型')
  847. return
  848. }
  849. if (!this.dataList[i].discAmount) {
  850. this.$errorMsg('请输入格力折扣')
  851. return
  852. }
  853. if (!this.dataList[i].price) {
  854. this.$errorMsg('请输入单价')
  855. return
  856. }
  857. if (!this.dataList[i].walletIds.length) {
  858. this.$errorMsg('请选择钱包')
  859. return
  860. }
  861. }
  862. savePolicy(this.dataList).then((res) => {
  863. this.dataList = []
  864. this.sleectBox.currentPage = 1
  865. this.$successMsg('保存成功')
  866. this.handletwoList()
  867. })
  868. },
  869. handleK3List(e, row) {
  870. const item = this.k3List.filter((k) => {
  871. return k.id == e
  872. })[0]
  873. // this.$set(row,'materialNumber',item.number)
  874. this.$set(row, 'materialName', item.name)
  875. this.$set(row, 'specification', item.specification)
  876. this.$set(row, 'materialId', item.id)
  877. this.getK3List()
  878. },
  879. handleReset() {
  880. Object.assign(this.$data, this.$options.data())
  881. }
  882. },
  883. components: {
  884. Transfer,
  885. AddCondition,
  886. ImageUpload
  887. }
  888. }
  889. </script>
  890. <style lang="scss" scoped>
  891. h4 {
  892. margin: 0;
  893. }
  894. .pdt {
  895. padding-top: 20px;
  896. }
  897. .import-btn {
  898. margin-right: 10px;
  899. display: inline-block;
  900. }
  901. .radio {
  902. padding: 20px 0;
  903. }
  904. .el-divider--horizontal {
  905. margin: 20px 0;
  906. }
  907. .el-container .el-divider--horizontal {
  908. margin: 10px;
  909. }
  910. .el-select {
  911. width: 100%;
  912. }
  913. .footer {
  914. margin-bottom: 20px;
  915. }
  916. </style>