editPolicy.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. <template>
  2. <div>
  3. <div v-show="isCondition == 0" class="app-container mymain-container">
  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="id"
  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 in typeList" :key="item.id" :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.fullscreen.lock="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. directives: {
  492. 'el-select-loadmore': {
  493. bind(el, binding) {
  494. console.log(el)
  495. // 获取element-ui定义好的scroll盒⼦
  496. const SELECTWRAP_DOM = el.querySelector(
  497. '.el-table__body-wrapper'
  498. // '.el-select-dropdown .el-select-dropdown__wrap'
  499. )
  500. SELECTWRAP_DOM.addEventListener('scroll', function () {
  501. /**
  502. * scrollHeight 获取元素内容⾼度(只读)
  503. * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
  504. * clientHeight 读取元素的可见⾼度(只读)
  505. * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
  506. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  507. */
  508. const condition = this.scrollHeight - this.scrollTop <= this.clientHeight
  509. if (condition) {
  510. binding.value()
  511. }
  512. })
  513. }
  514. }
  515. },
  516. mixins: [Minxin],
  517. data() {
  518. return {
  519. fang: false,
  520. input: '',
  521. baseURL: '',
  522. isCondition: 0,
  523. searchForm: {
  524. code: '',
  525. endTime: '',
  526. imgSrc: '',
  527. remark: '',
  528. startTime: '',
  529. title: '',
  530. mainId: '',
  531. mainName: '',
  532. type: '',
  533. isFullRebate: false,
  534. commercialType: false
  535. },
  536. conditName: '',
  537. dataList: [],
  538. addList: [],
  539. pageSizeArr: [10, 20, 30, 50],
  540. size: 10,
  541. listLoading: false,
  542. dialogVisible: false,
  543. importFileList: [],
  544. fileList: [],
  545. options: {},
  546. value: '',
  547. typeList: [],
  548. walletList: [],
  549. typeOptions: [
  550. {
  551. value: 'PROVISION',
  552. label: '配提'
  553. },
  554. {
  555. value: 'LIMIT',
  556. label: '限量'
  557. }
  558. ],
  559. conditionList: [],
  560. dictList: [],
  561. k3List: [],
  562. NoRebateWalletList: [],
  563. sleectBox: { currentPage: 1 },
  564. dpageSize: 10,
  565. dcurrentPage: 1,
  566. detail: {},
  567. rebateList: [],
  568. cid: '',
  569. cpolicyId: '',
  570. region: 0,
  571. fullscreenLoading:false,
  572. srcList:[]
  573. }
  574. },
  575. computed: {
  576. ...mapGetters({
  577. comCode: 'code'
  578. })
  579. },
  580. created() {
  581. // console.log(this.$store.code);
  582. // if (this.$parent.isFlag) {
  583. // // this.handletwoList()
  584. // }
  585. },
  586. methods: {
  587. ...mapMutations('sales', ['initData']),
  588. handleStatus(id, status) {
  589. setStauts({ policyMaterialId: id, status }).then(res => {
  590. this.handletwoList()
  591. this.$successMsg(status ? '启用' : '作废')
  592. })
  593. },
  594. setText(e, index, row, name) {
  595. this.dataList[index][name] = row[name]
  596. },
  597. // 下载excel模板
  598. handleDownloadFiles() {
  599. downloadFiles('policy/download')
  600. },
  601. handleCondition(id, index) {
  602. deleteCondition({ id }).then(res => {
  603. this.conditionList.splice(index, 1)
  604. Object.assign(this.$children[9].$data, this.$children[9].$options.data())
  605. this.$successMsg('删除成功')
  606. })
  607. },
  608. catCond(row) {
  609. this.cid = row.id
  610. this.$refs.cond.getCommonApi('', row.id)
  611. this.isCondition = 2
  612. // $refs.cond.getCommonApi(),
  613. // (), (cid = scope.row.id)
  614. },
  615. handleAddCondition() {
  616. this.isCondition = 1
  617. console.log(this.conditionList[0].id, this.searchForm.code)
  618. this.$refs.comDom.getCommonApi(this.conditionList[0].id)
  619. this.$store.commit('sales/setId', this.searchForm.code)
  620. },
  621. // loadmore() {
  622. // this.sleectBox.currentPage++
  623. // this.getK3List()
  624. // },
  625. loadmore2() {
  626. if (this.dataList.length < this.listTotal) {
  627. const total = Math.floor(this.listTotal / 10)
  628. if (this.dcurrentPage <= total) {
  629. this.dcurrentPage++
  630. this.handletwoList()
  631. }
  632. }
  633. },
  634. getK3List() {
  635. getK3List({
  636. pageNum: this.sleectBox.currentPage,
  637. pageSize: 10,
  638. keyword: ''
  639. }).then(res => {
  640. this.k3List = [...this.k3List, ...res.data.records]
  641. })
  642. },
  643. async remoteMethodType(query, type){
  644. console.log(111)
  645. // 获取销售类型列表
  646. const params = {
  647. pageNum: 1,
  648. pageSize:-1,
  649. saleCode:query,
  650. saleName: '',
  651. status: ''
  652. }
  653. const typeData = await getTypeList(params)
  654. this.typeList = typeData.data.records
  655. },
  656. remoteMethod(query, type) {
  657. console.log(query, type)
  658. if (query !== '') {
  659. getK3List({
  660. pageNum: 1,
  661. pageSize: 100,
  662. keyword: '',
  663. number: type === 'number' ? query : '',
  664. oldNumber: '',
  665. specification: type === 'specification' ? query : ''
  666. }).then(res => {
  667. this.k3List = res.data.records
  668. })
  669. } else {
  670. this.sleectBox.currentPage = 1
  671. this.getK3List()
  672. }
  673. },
  674. async getCommonApi() {
  675. // this.getK3List();
  676. // 非返利钱包
  677. const noRebateWalletData = await getNoRebateWalletList({
  678. walletName: ''
  679. })
  680. this.NoRebateWalletList = noRebateWalletData.data
  681. const walletRebateData = await getWalletRebateList({
  682. pageNum: 1,
  683. pageSize: -2,
  684. name: '',
  685. status: true
  686. })
  687. this.rebateList = walletRebateData.data.records
  688. const params = {
  689. pageNum: 1,
  690. pageSize: -1,
  691. saleCode: '',
  692. saleName: '',
  693. status: ''
  694. }
  695. // 获取销售类型列表
  696. const typeData = await getTypeList(params)
  697. this.typeList = typeData.data.records
  698. },
  699. handleSalesType(e, row, index, name) {
  700. const item = this.typeList.filter(k => {
  701. return k.id === e
  702. })[0]
  703. const linshi = []
  704. const rebateList = []
  705. this.rebateList.forEach(k => {
  706. k.saleTypes.forEach(j => {
  707. if (!linshi.includes(j.saleTypeId) && j.saleTypeId === e) {
  708. rebateList.push(k)
  709. linshi.push(j.saleTypeId)
  710. }
  711. })
  712. })
  713. if (rebateList.length) {
  714. this.dataList[index].rebateWalletIds = [...new Set([...row.rebateWalletIds, rebateList[0].walletRebateId])]
  715. this.$set(row, 'rebateWalletIds', [...new Set([...row.rebateWalletIds, rebateList[0].walletRebateId])])
  716. }
  717. this.dataList[index][name] = row[name]
  718. this.dataList[index].saleTypeCode = item.saleCode
  719. this.dataList[index].saleTypeName = item.saleName
  720. this.$set(row, 'saleTypeCode', item.saleCode)
  721. this.$set(row, 'saleTypeName', item.saleName)
  722. // this.$set(row,'saleTypeId',item.id)
  723. },
  724. // 修改条件名称
  725. handleConditionName(row) {
  726. console.log(row.name)
  727. if (this.conditName !== row.name) {
  728. updateCondition({ id: row.id, name: row.name }).then(res => {
  729. this.$successMsg('修改成功')
  730. })
  731. }
  732. row.fang = true
  733. },
  734. // 提交信息
  735. handleSubmitCon() {
  736. const params = {
  737. policyId: this.searchForm.code
  738. }
  739. // 获取条件政策
  740. getConditionList(params).then(res => {
  741. for (let i = 0; i < res.data.length; i++) {
  742. res.data[i].fang = true
  743. }
  744. this.conditionList = res.data
  745. Object.assign(this.$refs.comDom.$data, this.$refs.comDom.$options.data())
  746. })
  747. },
  748. // 视图部分已注释,废弃的功能 fucn
  749. handelStop() {
  750. if (this.searchForm.mainId) {
  751. this.fang = true
  752. } else {
  753. this.$errorMsg('请选择产品类别')
  754. }
  755. },
  756. // 导入
  757. async handleImport(param) {
  758. this.importLoading = true
  759. const file = param.file
  760. console.log(file, 123)
  761. const formData = new FormData()
  762. formData.append('file', file)
  763. formData.append('policyId', this.searchForm.code)
  764. // formData.append("mainId", this.searchForm.mainId);
  765. const result = await handleImport('/policy/material/import', formData)
  766. this.importLoading = false
  767. this.importFileList = []
  768. if (result.code === 200) {
  769. this.$successMsg('导入成功')
  770. this.dataList = []
  771. this.listTotal = 0
  772. this.sleectBox.currentPage = 1
  773. this.dcurrentPage = 1
  774. this.handletwoList()
  775. } else {
  776. this.$errorMsg(result.message)
  777. }
  778. },
  779. async getList() {
  780. await this.getCommonApi()
  781. await getPolicyDetail({ policyId: this.$parent.id }).then(async res => {
  782. this.detail = res.data
  783. ;(this.searchForm = {
  784. code: this.detail.code,
  785. endTime: this.detail.endTime,
  786. imgSrc: this.detail.imgSrc,
  787. remark: this.detail.remark,
  788. startTime: this.detail.startTime,
  789. title: this.detail.title,
  790. type: this.detail.type,
  791. isFullRebate: this.detail.isFullRebate,
  792. commercialType: this.detail.commercialType
  793. }),
  794. (this.region = res.data.flag)
  795. // this.srcList = [this.$imageUrl + this.detail.imgSrc]
  796. if (this.$parent.isShow === 5 && this.detail.imgSrc) {
  797. this.detail.imgSrc.split(',').forEach(k=>{
  798. this.fileList.push({
  799. hover: '',
  800. url:k
  801. })
  802. this.srcList.push(this.$imageUrl+k)
  803. })
  804. }
  805. await this.handletwoList()
  806. // 获取条件政策
  807. await this.handleSubmitCon()
  808. })
  809. if (this.$parent.isFlag) {
  810. await this.handletwoList()
  811. }
  812. },
  813. // 更改每页数量
  814. handleSizeChange1(val) {
  815. this.pageSize = val
  816. this.currentPage = 1
  817. this.handletwoList()
  818. },
  819. // 更改当前页
  820. handleCurrentChange1(val) {
  821. this.currentPage = val
  822. this.handletwoList()
  823. },
  824. // 更改每页数量
  825. handleSizeChange2(val) {
  826. this.dpageSize = val
  827. this.dcurrentPage = 1
  828. this.handletwoList()
  829. },
  830. // 更改当前页
  831. handleCurrentChange2(val) {
  832. this.dcurrentPage = val
  833. this.handletwoList()
  834. },
  835. // 获取货品信息
  836. handletwoList() {
  837. // this.searchForm.type
  838. this.listLoading = true
  839. const paramss = {
  840. pageNum: 1,
  841. pageSize: -1,
  842. policyId: this.searchForm.code,
  843. saleTypeCode: ''
  844. }
  845. getMaterialList(paramss)
  846. .then(result => {
  847. result.data.records.forEach(k => {
  848. k.fang = true
  849. k.walletIds = []
  850. k.rebateWalletIds = []
  851. if (!k.specification) {
  852. k.materialNumber = k.materialId
  853. k.specification = k.materialId
  854. }
  855. for (let i = 0; i < k.walletRelaList.length; i++) {
  856. const d = k.walletRelaList[i]
  857. d.id = d.walletId
  858. d.name = d.walletName
  859. if (d.type === 'REBATE') {
  860. k.rebateWalletIds = [...k.rebateWalletIds, d.walletId]
  861. } else {
  862. k.walletIds = [...k.walletIds, d.walletId]
  863. }
  864. }
  865. })
  866. this.dataList = result.data.records
  867. this.listTotal = result.data.total
  868. this.listLoading = false
  869. })
  870. .catch(err => {
  871. console.error(err)
  872. })
  873. },
  874. // 提交审核
  875. handlEditPolicy(policyCustomers, region) {
  876. if (!this.searchForm.title) {
  877. this.$errorMsg('请输入说明')
  878. return
  879. }
  880. if (!this.searchForm.type) {
  881. this.$errorMsg('请选择类型')
  882. return
  883. }
  884. if (!this.searchForm.startTime) {
  885. this.$errorMsg('请选择生效日期')
  886. return
  887. }
  888. const formtData = () => {
  889. var arr = []
  890. policyCustomers.forEach(el => {
  891. arr.push({
  892. customerId: el.customerId || el.customerId,
  893. customerName: el.name || el.customerName,
  894. customerNumber: el.number || el.customerNumber,
  895. lastOrderTime: '',
  896. limitTakeNum: 0,
  897. policyId: this.searchForm.code || this.detail.code,
  898. policyTitle: '',
  899. remark: ''
  900. })
  901. })
  902. // this.dictList.forEach((k) => {
  903. // if (k.dictCode == this.searchForm.mainId) {
  904. // this.searchForm.mainName = k.dictValue;
  905. // }
  906. // });
  907. let imgUrl = []
  908. this.fileList.forEach(k=>{
  909. imgUrl.push(k.url)
  910. })
  911. const params = {
  912. ...this.detail,
  913. ...this.searchForm,
  914. flag: region,
  915. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  916. policyCustomers: arr,
  917. imgSrc: imgUrl.join(',')
  918. }
  919. console.log(this.fileList)
  920. updatePolicy(params).then(res => {
  921. console.log(res)
  922. this.$successMsg('编辑成功')
  923. this.$parent.getList()
  924. this.$parent.isShow = 1
  925. })
  926. }
  927. if (region == 0) {
  928. if (policyCustomers.length) {
  929. formtData()
  930. } else {
  931. this.$errorMsg('选择经销商 ')
  932. }
  933. } else {
  934. formtData()
  935. }
  936. },
  937. // 删除
  938. handleDelete(id, index) {
  939. if (id) {
  940. const params = { policyMaterialId: id }
  941. deleteMaterialPolicy(params).then(res => {
  942. this.dataList.splice(index, 1)
  943. })
  944. return
  945. }
  946. this.dataList.splice(index, 1)
  947. if (!this.dataList.length) {
  948. this.dcurrentPage !== 1 ? (this.dcurrentPage -= 1) : (this.dcurrentPage = 1)
  949. }
  950. // this.listTotal -= 1;
  951. this.$successMsg('删除成功')
  952. },
  953. handleNewInfo() {
  954. // 物料列表
  955. this.dataList.push({
  956. id: '',
  957. discAmount: '',
  958. materialId: '',
  959. materialName: '',
  960. materialNumber: '',
  961. policyId: this.searchForm.code,
  962. price: '',
  963. remark: '',
  964. saleTypeCode: '',
  965. saleTypeId: '',
  966. saleTypeName: '',
  967. specification: '',
  968. walletIds: [this.NoRebateWalletList[0].id],
  969. walletRelaList: []
  970. })
  971. this.sleectBox.currentPage = 1
  972. // this.listTotal += 1;
  973. // this.dataList.push(this.addList[this.addList.length-1])
  974. },
  975. handleSave() {
  976. this.fullscreenLoading = true
  977. if (!this.dataList.length) {
  978. this.fullscreenLoading = false
  979. return
  980. }
  981. for (let i = 0; i < this.dataList.length; i++) {
  982. if (!this.dataList[i].materialId) {
  983. this.$errorMsg('请选择货品')
  984. return
  985. }
  986. if (!this.dataList[i].saleTypeId) {
  987. this.$errorMsg('请选择销售类型')
  988. return
  989. }
  990. if (!this.dataList[i].price) {
  991. this.$errorMsg('请输入单价')
  992. return
  993. }
  994. if (!this.dataList[i].walletIds.length) {
  995. this.$errorMsg('请选择现金钱包')
  996. return
  997. }
  998. }
  999. savePolicy(this.dataList).then(res => {
  1000. this.dataList = []
  1001. this.sleectBox.currentPage = 1
  1002. this.dcurrentPage = 1
  1003. this.fullscreenLoading = false
  1004. this.$successMsg('保存成功')
  1005. this.handletwoList()
  1006. })
  1007. },
  1008. handleK3List(e, row, index, name) {
  1009. const item = this.k3List.filter(k => {
  1010. return k.id == e
  1011. })[0]
  1012. this.$set(row, 'materialNumber', item.number)
  1013. this.$set(row, 'materialName', item.name)
  1014. this.$set(row, 'specification', item.specification)
  1015. this.$set(row, 'materialId', item.id)
  1016. this.dataList[index].materialNumber = item.number
  1017. this.dataList[index].materialName = item.name
  1018. this.dataList[index].specification = item.specification
  1019. this.dataList[index].materialId = item.id
  1020. this.getK3List()
  1021. },
  1022. handleReset() {
  1023. Object.assign(this.$data, this.$options.data())
  1024. this.getCommonApi()
  1025. }
  1026. },
  1027. components: {
  1028. // Transfer,
  1029. AddCondition,
  1030. ImageUpload,
  1031. EditCondition,
  1032. TabelTransfer,
  1033. PlTable,
  1034. PlTableColumn
  1035. }
  1036. }
  1037. </script>
  1038. <style lang="scss" scoped>
  1039. h4 {
  1040. margin: 0;
  1041. }
  1042. .yinput {
  1043. ::v-deep input {
  1044. text-align: right;
  1045. }
  1046. }
  1047. .pdt {
  1048. padding-top: 20px;
  1049. }
  1050. .import-btn {
  1051. margin-right: 10px;
  1052. display: inline-block;
  1053. }
  1054. .radio {
  1055. padding: 20px 0;
  1056. }
  1057. .el-divider--horizontal {
  1058. margin: 20px 0;
  1059. }
  1060. .el-container .el-divider--horizontal {
  1061. margin: 10px;
  1062. }
  1063. .el-select {
  1064. width: 100%;
  1065. }
  1066. .footer {
  1067. margin-bottom: 20px;
  1068. }
  1069. ::v-deep .el-table__virtual-wrapper {
  1070. width: auto !important;
  1071. }
  1072. </style>