editPolicy.vue 40 KB

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