AddPolicy.vue 31 KB

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