editPolicy.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  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="160px" 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, 'priceType', '')
  783. this.priceList = []
  784. // this.$set(row,'saleTypeId',item.id)
  785. },
  786. // 修改条件名称
  787. handleConditionName(row) {
  788. console.log(row.name)
  789. if (this.conditName !== row.name) {
  790. updateCondition({ id: row.id, name: row.name }).then(res => {
  791. this.$successMsg('修改成功')
  792. })
  793. }
  794. row.fang = true
  795. },
  796. // 提交信息
  797. handleSubmitCon() {
  798. const params = {
  799. policyId: this.searchForm.code
  800. }
  801. // 获取条件政策
  802. getConditionList(params).then(res => {
  803. for (let i = 0; i < res.data.length; i++) {
  804. res.data[i].fang = true
  805. }
  806. this.conditionList = res.data
  807. Object.assign(this.$refs.comDom.$data, this.$refs.comDom.$options.data())
  808. })
  809. },
  810. // 视图部分已注释,废弃的功能 fucn
  811. handelStop() {
  812. if (this.searchForm.mainId) {
  813. this.fang = true
  814. } else {
  815. this.$errorMsg('请选择产品类别')
  816. }
  817. },
  818. // 导入
  819. async handleImport(param) {
  820. this.importLoading = true
  821. const file = param.file
  822. console.log(file, 123)
  823. const formData = new FormData()
  824. formData.append('file', file)
  825. formData.append('policyId', this.searchForm.code)
  826. // formData.append("mainId", this.searchForm.mainId);
  827. const result = await handleImport('/policy/material/import', formData)
  828. this.importLoading = false
  829. this.importFileList = []
  830. if (result.code === 200) {
  831. this.$successMsg('导入成功')
  832. this.dataList = []
  833. this.listTotal = 0
  834. this.sleectBox.currentPage = 1
  835. this.dcurrentPage = 1
  836. this.handletwoList()
  837. } else {
  838. this.$errorMsg(result.message)
  839. }
  840. },
  841. async getList() {
  842. await this.getCommonApi()
  843. await getPolicyDetail({ policyId: this.id }).then(async res => {
  844. this.detail = res.data
  845. this.searchForm = {
  846. code: this.detail.code,
  847. endTime: this.detail.endTime,
  848. imgSrc: this.detail.imgSrc,
  849. remark: this.detail.remark,
  850. startTime: this.detail.startTime,
  851. title: this.detail.title,
  852. type: this.detail.type,
  853. isFullRebate: this.detail.isFullRebate,
  854. commercialType: this.detail.commercialType,
  855. maxBuyNum: this.detail.maxBuyNum,
  856. minBuyNum: this.detail.minBuyNum
  857. }
  858. this.region = res.data.flag
  859. // this.srcList = [this.$imageUrl + this.detail.imgSrc]
  860. if (this.isShow === 3 && this.detail.imgSrc) {
  861. this.detail.imgSrc.split(',').forEach(k => {
  862. this.fileList.push({
  863. hover: '',
  864. url: k
  865. })
  866. this.srcList.push(this.$imageUrl + k)
  867. })
  868. }
  869. await this.handletwoList()
  870. // 获取条件政策
  871. await this.handleSubmitCon()
  872. })
  873. if (this.isFlag) {
  874. await this.handletwoList()
  875. }
  876. },
  877. // 更改每页数量
  878. handleSizeChange1(val) {
  879. this.pageSize = val
  880. this.currentPage = 1
  881. this.handletwoList()
  882. },
  883. // 更改当前页
  884. handleCurrentChange1(val) {
  885. this.currentPage = val
  886. this.handletwoList()
  887. },
  888. // 更改每页数量
  889. handleSizeChange2(val) {
  890. this.dpageSize = val
  891. this.dcurrentPage = 1
  892. this.handletwoList()
  893. },
  894. // 更改当前页
  895. handleCurrentChange2(val) {
  896. this.dcurrentPage = val
  897. this.handletwoList()
  898. },
  899. // 获取货品信息
  900. handletwoList() {
  901. // this.searchForm.type
  902. this.listLoading = true
  903. const paramss = {
  904. pageNum: 1,
  905. pageSize: -1,
  906. policyId: this.searchForm.code,
  907. saleTypeCode: ''
  908. }
  909. getMaterialList(paramss)
  910. .then(result => {
  911. result.data.records.forEach(k => {
  912. k.fang = true
  913. k.walletIds = []
  914. k.rebateWalletIds = []
  915. if (!k.specification) {
  916. k.materialNumber = k.materialId
  917. k.specification = k.materialId
  918. }
  919. for (let i = 0; i < k.walletRelaList.length; i++) {
  920. const d = k.walletRelaList[i]
  921. d.id = d.walletId
  922. d.name = d.walletName
  923. if (d.type === 'REBATE') {
  924. k.rebateWalletIds = [...k.rebateWalletIds, d.walletId]
  925. } else {
  926. k.walletIds = [...k.walletIds, d.walletId]
  927. }
  928. }
  929. // this.priceList.forEach(l => {
  930. // if (l.priceTypeName == k.priceType) {
  931. // k.priceType = l.priceTypeId
  932. // }
  933. // })
  934. })
  935. this.dataList = result.data.records
  936. this.listTotal = result.data.total
  937. this.listLoading = false
  938. })
  939. .catch(err => {
  940. console.error(err)
  941. })
  942. },
  943. // 提交审核
  944. handlEditPolicy(policyCustomers, region) {
  945. if (!this.searchForm.title) {
  946. this.$errorMsg('请输入说明')
  947. return
  948. }
  949. if (!this.searchForm.type) {
  950. this.$errorMsg('请选择类型')
  951. return
  952. }
  953. if (!this.searchForm.startTime) {
  954. this.$errorMsg('请选择生效日期')
  955. return
  956. }
  957. const formtData = () => {
  958. var arr = []
  959. policyCustomers.forEach(el => {
  960. arr.push({
  961. customerId: el.customerId || el.customerId,
  962. customerName: el.name || el.customerName,
  963. customerNumber: el.number || el.customerNumber,
  964. lastOrderTime: '',
  965. limitTakeNum: 0,
  966. policyId: this.searchForm.code || this.detail.code,
  967. policyTitle: '',
  968. remark: ''
  969. })
  970. })
  971. // this.dictList.forEach((k) => {
  972. // if (k.dictCode == this.searchForm.mainId) {
  973. // this.searchForm.mainName = k.dictValue;
  974. // }
  975. // });
  976. const imgUrl = []
  977. this.fileList.forEach(k => {
  978. imgUrl.push(k.url)
  979. })
  980. const params = {
  981. ...this.detail,
  982. ...this.searchForm,
  983. flag: region,
  984. endTime: this.searchForm.endTime || '2100-01-01 00:00:00',
  985. policyCustomers: arr,
  986. imgSrc: imgUrl.join(',')
  987. }
  988. updatePolicy(params).then(res => {
  989. this.$successMsg('编辑成功')
  990. this.$emit('close')
  991. })
  992. }
  993. if (region == 0) {
  994. if (policyCustomers.length) {
  995. formtData()
  996. } else {
  997. this.$errorMsg('选择经销商 ')
  998. }
  999. } else {
  1000. formtData()
  1001. }
  1002. },
  1003. // 删除
  1004. handleDelete(id, index) {
  1005. if (id) {
  1006. const params = { policyMaterialId: id }
  1007. deleteMaterialPolicy(params).then(res => {
  1008. this.dataList.splice(index, 1)
  1009. })
  1010. return
  1011. }
  1012. this.dataList.splice(index, 1)
  1013. if (!this.dataList.length) {
  1014. this.dcurrentPage !== 1 ? (this.dcurrentPage -= 1) : (this.dcurrentPage = 1)
  1015. }
  1016. // this.listTotal -= 1;
  1017. this.$successMsg('删除成功')
  1018. },
  1019. handleNewInfo() {
  1020. // 物料列表
  1021. this.$nextTick(() => {
  1022. this.dataList.push({
  1023. id: '',
  1024. discAmount: '',
  1025. materialId: '',
  1026. materialName: '',
  1027. materialNumber: '',
  1028. policyId: this.searchForm.code,
  1029. price: '',
  1030. remark: '',
  1031. saleTypeCode: '',
  1032. saleTypeId: '',
  1033. saleTypeName: '',
  1034. specification: '',
  1035. walletIds: [this.NoRebateWalletList[0].id],
  1036. walletRelaList: [],
  1037. rebateWalletIds: []
  1038. })
  1039. this.sleectBox.currentPage = 1
  1040. })
  1041. // this.listTotal += 1;
  1042. // this.dataList.push(this.addList[this.addList.length-1])
  1043. },
  1044. handleSave() {
  1045. this.fullscreenLoading = true
  1046. if (!this.dataList.length) {
  1047. this.fullscreenLoading = false
  1048. return
  1049. }
  1050. for (let i = 0; i < this.dataList.length; i++) {
  1051. if (!this.dataList[i].materialId) {
  1052. this.$errorMsg('请选择货品')
  1053. return
  1054. }
  1055. if (!this.dataList[i].saleTypeId) {
  1056. this.$errorMsg('请选择销售类型')
  1057. return
  1058. }
  1059. if (!this.dataList[i].price) {
  1060. this.$errorMsg('请输入单价')
  1061. return
  1062. }
  1063. if (!this.dataList[i].walletIds.length) {
  1064. this.$errorMsg('请选择现金钱包')
  1065. return
  1066. }
  1067. }
  1068. savePolicy(this.dataList)
  1069. .then(res => {
  1070. this.dataList = []
  1071. this.sleectBox.currentPage = 1
  1072. this.dcurrentPage = 1
  1073. this.fullscreenLoading = false
  1074. this.$successMsg('保存成功')
  1075. this.handletwoList()
  1076. })
  1077. .finally(() => {
  1078. this.fullscreenLoading = false
  1079. })
  1080. },
  1081. handleK3List(e, row, index, name) {
  1082. const item = this.k3List.filter(k => {
  1083. return k.id == e
  1084. })[0]
  1085. this.$set(row, 'materialNumber', item.number)
  1086. this.$set(row, 'materialName', item.name)
  1087. this.$set(row, 'specification', item.specification)
  1088. this.$set(row, 'materialId', item.id)
  1089. this.dataList[index].materialNumber = item.number
  1090. this.dataList[index].materialName = item.name
  1091. this.dataList[index].specification = item.specification
  1092. this.dataList[index].materialId = item.id
  1093. this.getK3List()
  1094. },
  1095. handleReset() {
  1096. Object.assign(this.$data, this.$options.data())
  1097. this.getCommonApi()
  1098. },
  1099. handleBack() {
  1100. this.isCondition = 0
  1101. this.$emit('upDataIsFlag')
  1102. },
  1103. getPriceSalesRelaListV2(val) {
  1104. getPriceSalesRelaListV2({
  1105. pageNum: 1,
  1106. pageSize: -1,
  1107. params: [
  1108. {
  1109. 'param': 'b.sale_code',
  1110. 'compare': 'like',
  1111. 'value': val
  1112. }
  1113. ]
  1114. }).then(res => {
  1115. this.priceList = res.data.records
  1116. })
  1117. },
  1118. handlePriceType(e) {
  1119. if (e.saleTypeCode) {
  1120. this.getPriceSalesRelaListV2(e.saleTypeCode)
  1121. }
  1122. }
  1123. },
  1124. components: {
  1125. // Transfer,
  1126. AddCondition,
  1127. ImageUpload,
  1128. TabelTransfer,
  1129. PlTable,
  1130. PlTableColumn
  1131. }
  1132. }
  1133. </script>
  1134. <style lang="scss" scoped>
  1135. ::v-deep .elImageClose .el-image-viewer__wrapper span[class='el-image-viewer__btn el-image-viewer__close'] {
  1136. top: 100px;
  1137. }
  1138. h4 {
  1139. margin: 0;
  1140. }
  1141. .yinput {
  1142. ::v-deep input {
  1143. text-align: right;
  1144. }
  1145. }
  1146. .pdt {
  1147. padding-top: 20px;
  1148. }
  1149. .import-btn {
  1150. margin-right: 10px;
  1151. display: inline-block;
  1152. }
  1153. .radio {
  1154. padding: 20px 0;
  1155. }
  1156. .el-divider--horizontal {
  1157. margin: 20px 0;
  1158. }
  1159. .el-container .el-divider--horizontal {
  1160. margin: 10px;
  1161. }
  1162. .el-select {
  1163. width: 100%;
  1164. }
  1165. .footer {
  1166. margin-bottom: 20px;
  1167. }
  1168. ::v-deep .el-table__virtual-wrapper {
  1169. width: auto !important;
  1170. }
  1171. </style>