editPolicy.vue 37 KB

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