AddPolicy.vue 34 KB

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