editPolicy.vue 40 KB

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