editPolicy.vue 37 KB

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