AddPolicy.vue 35 KB

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