retail_form.vue 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header
  4. :content="listItem ? '编辑' : '新增'"
  5. @back="goBack"
  6. />
  7. <div class="main-title">
  8. <div class="title">订单信息</div>
  9. </div>
  10. <el-form
  11. ref="mainForm"
  12. :model="mainForm"
  13. label-width="120px"
  14. size="small"
  15. label-position="right"
  16. >
  17. <el-row :gutter="20">
  18. <el-col :xs="24" :sm="12" :lg="8">
  19. <el-form-item label="销售政策编号" prop="policyCode">
  20. <div style="display: flex">
  21. <el-input
  22. v-model="policyId"
  23. placeholder="销售政策编号"
  24. disabled
  25. />
  26. <el-button
  27. style="margin-left: 10px"
  28. size="small"
  29. @click="handleShow"
  30. >引用</el-button>
  31. </div>
  32. </el-form-item>
  33. </el-col>
  34. <!-- <el-col :xs="24" :sm="12" :lg="8" v-else>
  35. <el-form-item label="销售政策编号" prop="policyCode">
  36. <el-input
  37. disabled
  38. v-model="mainForm.policyId"
  39. placeholder="销售政策编号"
  40. ></el-input>
  41. </el-form-item>
  42. </el-col> -->
  43. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  44. <el-form-item label="单据日期" prop="date">
  45. <el-date-picker
  46. v-model="mainForm.date"
  47. type="datetime"
  48. disabled
  49. style="width: 100%"
  50. placeholder="选择日期"
  51. />
  52. </el-form-item>
  53. </el-col>
  54. <el-col :xs="24" :sm="8" :lg="8">
  55. <el-form-item label="备注" prop="remark">
  56. <el-input
  57. v-model="mainForm.remark"
  58. placeholder="请输入备注"
  59. />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :xs="24" :sm="12" :lg="8">
  63. <el-form-item label="业务员" prop="k3ServiceName">
  64. <el-select
  65. v-model="mainForm.k3ServiceName"
  66. placeholder="选择业务员"
  67. disabled
  68. style="width: 100%"
  69. @change="handleUser"
  70. >
  71. <el-option
  72. v-for="item in userList"
  73. :key="item.adminUserId"
  74. :label="item.nickName"
  75. :value="item.adminUserId"
  76. />
  77. </el-select>
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </el-form>
  82. <div class="main-title">
  83. <div class="title">货品信息</div>
  84. <div>
  85. <el-select
  86. v-model="warehouseValue"
  87. placeholder="请选择发货仓库"
  88. size="small"
  89. style="margin-right: 10px"
  90. >
  91. <el-option
  92. v-for="(item, index) in warehouseList"
  93. :key="index"
  94. :label="item.name"
  95. :value="item.id"
  96. />
  97. </el-select>
  98. <el-button
  99. type="primary"
  100. size="small"
  101. icon="el-icon-search"
  102. @click="checkStock"
  103. >检查库存</el-button>
  104. <el-divider direction="vertical" />
  105. </div>
  106. </div>
  107. <div class="table" >
  108. <el-table
  109. :data="goodsList"
  110. element-loading-text="Loading"
  111. border
  112. fit
  113. highlight-current-row
  114. stripe
  115. max-height="400"
  116. >
  117. <el-table-column
  118. align="center"
  119. label="序号"
  120. type="index"
  121. width="50"
  122. />
  123. <el-table-column
  124. align="center"
  125. label="销售类型"
  126. prop="saleTypeName"
  127. min-width="100"
  128. show-overflow-tooltip
  129. />
  130. <el-table-column
  131. align="center"
  132. label="存货编码"
  133. prop="materialNumber"
  134. min-width="100"
  135. show-overflow-tooltip
  136. >
  137. <template slot-scope="scope">
  138. {{ scope.row.materialNumber?scope.row.materialNumber:scope.row.materialCode }}
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. align="center"
  143. label="产品名称"
  144. prop="materialName"
  145. min-width="160"
  146. show-overflow-tooltip
  147. />
  148. <el-table-column
  149. align="center"
  150. label="规格型号"
  151. prop="specification"
  152. min-width="160"
  153. show-overflow-tooltip
  154. />
  155. <el-table-column
  156. align="center"
  157. label="单位"
  158. prop="unit"
  159. min-width="100"
  160. show-overflow-tooltip
  161. />
  162. <el-table-column
  163. align="center"
  164. label="单价"
  165. prop="price"
  166. min-width="100"
  167. show-overflow-tooltip
  168. />
  169. <el-table-column
  170. align="center"
  171. label="总数量"
  172. prop="qty"
  173. min-width="100"
  174. show-overflow-tooltip
  175. >
  176. <template slot-scope="scope">
  177. <el-input v-model="scope.row.qty" size="small" />
  178. </template>
  179. </el-table-column>
  180. <el-table-column
  181. align="center"
  182. label="订单金额"
  183. min-width="100"
  184. show-overflow-tooltip
  185. >
  186. <template slot-scope="scope">
  187. {{ scope.row.price * scope.row.qty }}
  188. </template>
  189. </el-table-column>
  190. <el-table-column
  191. align="center"
  192. label="返利钱包"
  193. prop="customerWalletId2"
  194. min-width="160"
  195. show-overflow-tooltip
  196. >
  197. <template slot-scope="scope">
  198. <el-select
  199. v-model="scope.row.customerWalletId2"
  200. placeholder="选择返利钱包"
  201. clearable
  202. size="small"
  203. @remove-tag="clearWallet($event,scope.row)"
  204. @change="changeWallet($event,scope.row)"
  205. >
  206. <el-option
  207. v-for="item in scope.row.rebateWallets"
  208. :key="item.customerWalletId"
  209. :label="item.name"
  210. :value="item.customerWalletId"
  211. />
  212. </el-select>
  213. </template>
  214. </el-table-column>
  215. <el-table-column
  216. align="center"
  217. label="返利金额"
  218. min-width="100"
  219. show-overflow-tooltip
  220. >
  221. <template slot-scope="scope">
  222. {{
  223. ((scope.row.price - scope.row.discAmount)*((scope.row.rebateRate * scope.row.qty) * 100)/100 || 0 ).toFixed(2)
  224. }}
  225. </template>
  226. </el-table-column>
  227. <el-table-column
  228. align="center"
  229. label="格力折扣"
  230. min-width="100"
  231. show-overflow-tooltip
  232. >
  233. <template slot-scope="scope">
  234. {{ scope.row.qty * scope.row.discAmount }}
  235. </template>
  236. </el-table-column>
  237. <el-table-column
  238. align="center"
  239. label="现金钱包"
  240. prop="customerWalletId"
  241. min-width="160"
  242. show-overflow-tooltip
  243. >
  244. <template slot-scope="scope">
  245. <el-select
  246. v-model="scope.row.customerWalletId"
  247. placeholder="选择现金钱包"
  248. clearable
  249. size="small"
  250. @change="handleWallets($event, scope.row,scope.$index)"
  251. >
  252. <el-option
  253. v-for="item in scope.row.wallets"
  254. :key="item.customerWalletId"
  255. :label="item.name"
  256. :value="item.customerWalletId"
  257. />
  258. </el-select>
  259. </template>
  260. </el-table-column>
  261. <el-table-column
  262. align="center"
  263. label="业务员"
  264. prop="retiredQty"
  265. min-width="160"
  266. show-overflow-tooltip
  267. >
  268. <template slot-scope="scope">
  269. <el-select
  270. v-model="scope.row.serviceName"
  271. size="small"
  272. disabled
  273. placeholder="选择业务员"
  274. style="width: 100%"
  275. @change="handleUser2($event,scope.row)"
  276. >
  277. <el-option
  278. v-for="item in scope.row.userList"
  279. :key="item.adminUserId"
  280. :label="item.nickName"
  281. :value="item.adminUserId"
  282. />
  283. </el-select>
  284. </template>
  285. </el-table-column>
  286. <el-table-column
  287. align="center"
  288. label="实付金额"
  289. prop="qty"
  290. min-width="100"
  291. show-overflow-tooltip
  292. >
  293. <template slot-scope="scope">
  294. <template v-if="scope.row.rebateRate">
  295. {{ (((scope.row.price * scope.row.qty) * 100 - ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 - ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) / 100).toFixed(2) }}
  296. </template>
  297. <template v-else>
  298. {{ (scope.row.price*scope.row.qty ).toFixed(2)}}
  299. </template>
  300. </template>
  301. </el-table-column>
  302. <el-table-column
  303. align="center"
  304. label="是否直调"
  305. prop="isDirectTransfer"
  306. min-width="100"
  307. >
  308. <template slot-scope="scope">
  309. <el-checkbox v-model="scope.row.isDirectTransfer" />
  310. </template>
  311. </el-table-column>
  312. <!-- <el-table-column
  313. align="center"
  314. label="直调数量"
  315. prop="directTransferQty"
  316. min-width="100"
  317. >
  318. <template slot-scope="scope">
  319. <el-input
  320. v-model="scope.row.directTransferQty"
  321. size="small"
  322. ></el-input>
  323. </template>
  324. </el-table-column> -->
  325. <el-table-column
  326. align="center"
  327. label="备注"
  328. prop="remark"
  329. min-width="160"
  330. >
  331. <template slot-scope="scope">
  332. <el-input v-model="scope.row.remark" size="small" />
  333. </template>
  334. </el-table-column>
  335. <el-table-column
  336. align="center"
  337. label="税率"
  338. prop="tax"
  339. min-width="100"
  340. show-overflow-tooltip
  341. />
  342. <el-table-column
  343. v-if="!listItem"
  344. align="center"
  345. label="总仓库"
  346. prop="status1"
  347. min-width="100"
  348. show-overflow-tooltip
  349. >
  350. <template slot-scope="scope">
  351. <div>{{ scope.row.status1 | status1Filter }}</div>
  352. </template>
  353. </el-table-column>
  354. <el-table-column
  355. v-if="!listItem"
  356. align="center"
  357. label="仓库状态"
  358. prop="status2"
  359. min-width="100"
  360. show-overflow-tooltip
  361. >
  362. <template slot-scope="scope">
  363. <div>{{ status2Filter(scope.row) }}</div>
  364. </template>
  365. </el-table-column>
  366. <el-table-column align="center" label="操作" width="100" fixed="right">
  367. <template slot-scope="scope">
  368. <!-- <el-button
  369. type="text"
  370. @click="(dialogVisible = true), (cid = scope.row.id)"
  371. >修改</el-button
  372. > -->
  373. <el-button
  374. type="text"
  375. @click="deleteItem(scope.$index, scope.row.id)"
  376. >删除</el-button>
  377. </template>
  378. </el-table-column>
  379. </el-table>
  380. </div>
  381. <div class="page-footer">
  382. <div class="footer" :class="classObj">
  383. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  384. <el-popconfirm
  385. title="确定关闭吗?"
  386. style="margin-left: 10px"
  387. @onConfirm="goBack"
  388. >
  389. <el-button slot="reference">关 闭</el-button>
  390. </el-popconfirm>
  391. </div>
  392. </div>
  393. <el-dialog
  394. :visible.sync="isShowDialog"
  395. width="80%"
  396. :close-on-click-modal="false"
  397. title="引用销售政策"
  398. @close="handleClose"
  399. >
  400. <template>
  401. <el-form
  402. ref="screenForm"
  403. :model="screenForm"
  404. label-width="120px"
  405. size="small"
  406. >
  407. <el-row v-if="factor.length && !dataList.length" style="margin: 0 0 20px 0;font-size: 20px;">
  408. 引用销售政策说明:{{!remark ? factor[0].name : remark }} 配提比列:{{pop}}
  409. </el-row>
  410. <el-row :gutter="20">
  411. <el-col :xs="24" :sm="6" :lg="6">
  412. <el-form-item label="销售政策">
  413. <el-select
  414. v-model="screenForm.policyId"
  415. placeholder="选择销售政策"
  416. filterable
  417. :disabled="disabled"
  418. style="width: 100%"
  419. @change="handlePolicy"
  420. >
  421. <el-option label="默认" :value="''" />
  422. <el-option
  423. v-for="(item, index) in policyList"
  424. :key="index"
  425. :label="item.title"
  426. :value="item.code"
  427. />
  428. </el-select> </el-form-item></el-col>
  429. <!-- <el-col :xs="24" :sm="6" :lg="6">
  430. <el-form-item label="条件">
  431. <el-select
  432. v-model="screenForm.factorId"
  433. filterable
  434. @change="handleFactor"
  435. placeholder="选择条件"
  436. style="width: 100%"
  437. >
  438. <el-option
  439. v-for="(item, index) in factor"
  440. :key="item.id"
  441. :label="'条件' + (index + 1)"
  442. :value="item.id"
  443. ></el-option>
  444. </el-select>
  445. </el-form-item>
  446. </el-col> -->
  447. <el-col :xs="24" :sm="6" :lg="6">
  448. <el-form-item label="销售类型">
  449. <el-select
  450. v-model="screenForm.saleTypeCode"
  451. filterable
  452. placeholder="选择销售类型"
  453. style="width: 100%"
  454. >
  455. <el-option label="默认" :value="''" />
  456. <el-option
  457. v-for="item in ztypeList"
  458. :key="item.id"
  459. :label="item.saleName"
  460. :value="item.saleCode"
  461. />
  462. </el-select>
  463. </el-form-item>
  464. </el-col>
  465. <el-col :xs="24" :sm="12" :lg="12" class="tr">
  466. <el-button
  467. type="primary"
  468. size="small"
  469. @click="handlePolicyTypeList"
  470. >查询</el-button>
  471. </el-col>
  472. </el-row>
  473. </el-form>
  474. <template v-if="!dataList.length">
  475. <div v-for="(item, index) in popDataArr" :key="index">
  476. <div style="padding: 20px 0">
  477. <div v-if="index == 0">限定机型</div>
  478. <div v-else>配提机型{{ index }}</div>
  479. </div>
  480. <el-table
  481. ref="singleTable"
  482. v-loading="listLoading"
  483. class="table"
  484. :data="item"
  485. element-loading-text="Loading"
  486. max-height="500"
  487. border
  488. fit
  489. highlight-current-row
  490. stripe
  491. @select-all="handleSelectionChange($event, 1, index)"
  492. @selection-change="handleSelectionChange($event, 1, index)"
  493. >
  494. <el-table-column
  495. align="center"
  496. type="selection"
  497. :selectable="selectable"
  498. width="55"
  499. />
  500. <template v-for="col in columns">
  501. <el-table-column
  502. v-if="col.num"
  503. align="center"
  504. :label="col.lable"
  505. :prop="col.prop"
  506. :min-width="col.widht"
  507. show-overflow-tooltip
  508. >
  509. <template slot-scope="scope">
  510. <el-input
  511. v-model.lazy="scope.row.qty"
  512. type="number"
  513. size="small"
  514. @blur="blurQty(scope.row.qty, scope.row)"
  515. @input="funQty(scope.row.qty, scope.row, index)"
  516. />
  517. </template>
  518. </el-table-column>
  519. <el-table-column
  520. v-else-if="col.jie"
  521. align="center"
  522. :label="col.lable"
  523. :prop="col.prop"
  524. :min-width="col.widht"
  525. show-overflow-tooltip
  526. >
  527. <template slot-scope="scope">
  528. {{ scope.row.qty * scope.row.price || 0 }}
  529. </template>
  530. </el-table-column>
  531. <el-table-column
  532. v-else
  533. align="center"
  534. :label="col.lable"
  535. :prop="col.prop"
  536. :min-width="col.widht"
  537. show-overflow-tooltip
  538. />
  539. </template>
  540. <template #append>
  541. <div class="mybox">
  542. <el-row class="mybox-row" type="flex">
  543. <el-col style="width: 55px">合计</el-col>
  544. <el-col />
  545. <el-col />
  546. <el-col />
  547. <el-col>{{ totalArr[index].totalQty }}</el-col>
  548. <el-col>{{ totalArr[index].totalPrice }}</el-col>
  549. <el-col>{{ totalArr[index].totalAmount }}</el-col>
  550. </el-row>
  551. </div>
  552. </template>
  553. </el-table>
  554. <!-- <div style="margin: 10px 0">
  555. 分页
  556. <el-pagination
  557. @size-change="
  558. popfun['handleSizeChange' + (index + 1)]($event, index + 1)
  559. "
  560. @current-change="
  561. popfun['handleCurrentChange' + (index + 1)]($event, index + 1)
  562. "
  563. :current-page="popcun['cun' + (index + 1)]"
  564. :page-sizes="[10]"
  565. :page-size="10"
  566. layout="total, sizes, prev, pager, next, jumper"
  567. :total="poptotal['total' + (index + 1)]"
  568. >
  569. </el-pagination>
  570. </div> -->
  571. </div>
  572. <!-- <div v-if="factor.length">-->
  573. <!-- 引用销售政策说明:{{ factor.length ? factor[0].name : "" }} 配提比列:{{pop}}-->
  574. <!-- </div>-->
  575. <span slot="footer" class="dialog-footer">
  576. <el-button type="primary" @click="hanlePopData">完成</el-button>
  577. </span>
  578. </template>
  579. <template v-else>
  580. <el-table
  581. ref="singleTable"
  582. v-loading="listLoading2"
  583. class="table"
  584. :data="dataList"
  585. element-loading-text="Loading"
  586. border
  587. fit
  588. max-height="500"
  589. highlight-current-row
  590. stripe
  591. @select-all="handleSelectionChange"
  592. @selection-change="handleSelectionChange"
  593. >
  594. <el-table-column
  595. align="center"
  596. type="selection"
  597. :selectable="selectable2"
  598. width="55"
  599. />
  600. <template v-for="col in columns">
  601. <el-table-column
  602. v-if="col.num"
  603. align="center"
  604. :label="col.lable"
  605. :prop="col.prop"
  606. :min-width="col.widht"
  607. show-overflow-tooltip
  608. >
  609. <template slot-scope="scope">
  610. <el-input
  611. v-model.lazy="scope.row.qty"
  612. type="number"
  613. size="small"
  614. @blur="blurQty(scope.row.qty, scope.row)"
  615. @input="funQty(scope.row.qty, scope.row)"
  616. />
  617. </template>
  618. </el-table-column>
  619. <el-table-column
  620. v-else-if="col.jie"
  621. align="center"
  622. :label="col.lable"
  623. :prop="col.prop"
  624. :min-width="col.widht"
  625. show-overflow-tooltip
  626. >
  627. <template slot-scope="scope">
  628. {{ scope.row.qty * scope.row.price || 0 }}
  629. </template>
  630. </el-table-column>
  631. <el-table-column
  632. v-else
  633. align="center"
  634. :label="col.lable"
  635. :prop="col.prop"
  636. :min-width="col.widht"
  637. show-overflow-tooltip
  638. />
  639. </template>
  640. <template #append>
  641. <div class="mybox">
  642. <el-row class="mybox-row" type="flex">
  643. <el-col style="width: 55px;">合计</el-col>
  644. <el-col />
  645. <el-col />
  646. <el-col />
  647. <el-col>{{ totalQty }}</el-col>
  648. <el-col>{{ totalPrice }}</el-col>
  649. <el-col>{{ totalAmount }}</el-col>
  650. </el-row>
  651. </div>
  652. </template>
  653. </el-table>
  654. <!-- <div style="margin: 10px 0">
  655. <el-pagination
  656. @size-change="handleSizeChange"
  657. @current-change="handleCurrentChange"
  658. :current-page="currentPage"
  659. :page-sizes="[10]"
  660. :page-size="10"
  661. layout="total, sizes, prev, pager, next, jumper"
  662. :total="total"
  663. >
  664. </el-pagination>
  665. </div> -->
  666. <span slot="footer" class="dialog-footer">
  667. <el-button type="primary" @click="hanlePopData">完成</el-button>
  668. </span>
  669. </template>
  670. </template>
  671. </el-dialog>
  672. </div>
  673. </template>
  674. <script>
  675. import {
  676. addData,
  677. checkStock,
  678. editData,
  679. getConditionList,
  680. getDetail,
  681. getGoodsList,
  682. getMaterialTypeList,
  683. getPolicyConditionList,
  684. getpolicyList,
  685. getpolicyTypeList,
  686. getSalesTypeList,
  687. getUserList,
  688. getWalletList,
  689. getWarehouseList,
  690. policyList,
  691. typeList
  692. } from '@/api/supply/policy'
  693. import { getDictList } from '@/api/common'
  694. export default {
  695. name: 'RetailForm',
  696. componentName: 'RetailForm',
  697. filters: {
  698. status1Filter(val) {
  699. if (val === '' || val === null || val === undefined) return '未检查'
  700. else if (val === 0) return '无货'
  701. else if (val > 0 && val <= 30) return val
  702. else if (val > 30 && val <= 1000) return '有货'
  703. else if (val > 1000) return '充足'
  704. }
  705. },
  706. props: ['listItem'],
  707. data() {
  708. return {
  709. tableData: [],
  710. currentPage: 1, // 当前页码
  711. pageSize: 10, // 每页数量
  712. listTotal: 0, // 列表总数
  713. cusIndex: 0,
  714. total: 0,
  715. radio: '',
  716. pop: '',
  717. dialogVisible: false,
  718. factor: [],
  719. popArr: [],
  720. mainForm: {
  721. id: '',
  722. date: '',
  723. type: '',
  724. ztype: '',
  725. remark: '',
  726. policyCode: '',
  727. policyRemark: '',
  728. policyId: '',
  729. k3ServiceId: '',
  730. k3ServiceName: ''
  731. },
  732. // mainFormRules: {
  733. // type: [{ required: true, message: "请选择品类", trigger: "change" }],
  734. // },
  735. goodsList: [],
  736. warehouseList: [],
  737. warehouseValue: '',
  738. isShowDialog: false,
  739. screenForm: {
  740. policyId: '',
  741. saleTypeCode: '',
  742. factorId: ''
  743. },
  744. currentPage: 1,
  745. listTotal: 0,
  746. salesTypeList: [],
  747. typeList: [],
  748. ztypeList: [],
  749. leftGoodsList: [],
  750. rightGoodsList: [],
  751. leftSelection: [],
  752. rightSelection: [],
  753. policyList: [],
  754. xjWalletList: [],
  755. flWalletList: [],
  756. dataList: [],
  757. columns: [
  758. {
  759. prop: 'saleTypeName',
  760. lable: '销售类型',
  761. widht: 160
  762. },
  763. {
  764. prop: 'materialName',
  765. lable: '货品名称',
  766. widht: 160
  767. },
  768. {
  769. prop: 'specification',
  770. lable: '规格型号',
  771. widht: 160
  772. },
  773. {
  774. prop: 'qty',
  775. lable: '数量',
  776. widht: 160,
  777. num: true
  778. },
  779. {
  780. prop: 'price',
  781. lable: '单价',
  782. widht: 160
  783. },
  784. {
  785. prop: 'zong',
  786. widht: 160,
  787. lable: '金额',
  788. jie: true
  789. }
  790. ],
  791. listLoading: false,
  792. listLoading2: false,
  793. popDataArr: [],
  794. radioObj: {},
  795. step: 0,
  796. policyId: '',
  797. policyConditionId: '',
  798. multipleSelection: [],
  799. multipleSelections: [],
  800. multipleData: [],
  801. disabled: false,
  802. cid: '',
  803. newDataList: [],
  804. userList: [],
  805. fang: false,
  806. popfun: {},
  807. poptotal: {},
  808. popcun: {},
  809. totalQty: 0,
  810. totalPrice: 0,
  811. totalAmount: 0,
  812. totalArr: [],
  813. type: 1,
  814. newMultipleSelections: [],
  815. remark:''
  816. }
  817. },
  818. computed: {
  819. sidebar() {
  820. // console.log(11145454);
  821. return this.$store.state.app.sidebar
  822. },
  823. classObj() {
  824. return {
  825. hideSidebar: !this.sidebar.opened,
  826. openSidebar: this.sidebar.opened
  827. }
  828. },
  829. comxjWalletList() {
  830. return (c) => {
  831. // // consloe(c, "现金钱包");
  832. const walle = []
  833. const ovalVall = c == undefined || !c.length ? [] : c
  834. for (let i = 0; i < this.xjWalletList.length; i++) {
  835. for (let j = 0; j < ovalVall.length; j++) {
  836. if (this.xjWalletList[i].walletRebateId == ovalVall[j].walletId) {
  837. walle.push(this.xjWalletList[i])
  838. }
  839. }
  840. }
  841. return walle
  842. }
  843. },
  844. comText() {
  845. return (val) => {
  846. if (this.cusIndex - 1 == 0) {
  847. const params = this.radio.split('&')
  848. return this.dataList.filter((k) => {
  849. return k.id == params[0]
  850. })[0][val]
  851. } else {
  852. const params =
  853. this.radioObj['radio' + (this.cusIndex - 1)].split('&')
  854. return this.popDataArr[this.cusIndex - 2].filter((k) => {
  855. return k.id == params[0]
  856. })[0][val]
  857. }
  858. }
  859. }
  860. // pickerOptions({ $props }) {
  861. // return {
  862. // disabledDate: (time) => {
  863. // return time.getTime() < Date.now() - 1 * 24 * 60 * 60 * 1000;
  864. // },
  865. // };
  866. // },
  867. },
  868. created() {
  869. this.getDictList()
  870. this.getWalletList()
  871. this.getWarehouseList()
  872. this.getTypeList()
  873. this.getUserList()
  874. if (this.listItem) {
  875. this.getDetail()
  876. }
  877. },
  878. methods: {
  879. blurQty(e, row) {
  880. if (!e) {
  881. this.$set(row, 'qty', 1)
  882. }
  883. },
  884. funQty(qty, row, index) {
  885. if (row.fang) {
  886. if (this.type == 1) {
  887. this.$set(this.totalArr, index, {
  888. totalQty: 0,
  889. totalPrice: 0,
  890. totalAmount: 0
  891. })
  892. for (let j = 0; j < this.multipleSelections[index].length; j++) {
  893. this.multipleSelections[index][j].fang = true
  894. this.totalArr[index].totalQty += +qty || 1
  895. this.totalArr[index].totalPrice +=
  896. +this.multipleSelections[index][j].price
  897. this.totalArr[index].totalAmount +=
  898. +this.multipleSelections[index][j].price * (+qty || 1)
  899. }
  900. } else {
  901. this.totalQty = this.totalPrice = this.totalAmount = 0
  902. for (let i = 0; i < this.multipleSelection.length; i++) {
  903. this.totalQty += +qty || 1
  904. this.totalPrice += +this.multipleSelection[i].price
  905. this.totalAmount +=
  906. +this.multipleSelection[i].price * (+qty || 1)
  907. }
  908. }
  909. }
  910. },
  911. getUserList() {
  912. getUserList({
  913. pageNum: 1,
  914. pageSize: -1,
  915. adminWebsitId: '',
  916. isCustomer: 0,
  917. roleId: '',
  918. status: true,
  919. userName: ''
  920. }).then((res) => {
  921. this.userList = res.data.records
  922. // // consloe(this.userList,'122');
  923. })
  924. },
  925. handleUser(e) {
  926. const user = this.userList.filter(k => {
  927. return k.adminUserId == e
  928. })[0]
  929. this.mainForm.k3ServiceId = user.adminUserId
  930. this.mainForm.k3ServiceName = user.nickName
  931. },
  932. handleUser2(e, row) {
  933. const user = this.userList.filter(k => {
  934. return k.adminUserId == e
  935. })[0]
  936. this.$set(row, 'serviceId', user.adminUserId)
  937. this.$set(row, 'serviceName', user.nickName)
  938. this.$set(this.mainForm,'k3ServiceId',user.adminUserId)
  939. this.$set(this.mainForm,'k3ServiceName',user.nickName)
  940. },
  941. // 返回列表
  942. goBack() {
  943. this.$emit('backListFormDetail')
  944. },
  945. handleWallets(e, row,index) {
  946. if (e) {
  947. const service = row.wallets.filter((k) => {
  948. return e == k.customerWalletId
  949. })[0]
  950. this.$set(this.mainForm, 'k3ServiceId', service.serviceId)
  951. this.$set(this.mainForm, 'k3ServiceName', service.serviceName)
  952. this.$set(row, 'serviceId', service.serviceId)
  953. this.$set(row, 'serviceName', service.serviceName)
  954. }else {
  955. console.log(index)
  956. if (index ===0){
  957. this.$set(this.mainForm, 'k3ServiceId', '')
  958. this.$set(this.mainForm, 'k3ServiceName', '')
  959. }
  960. this.$set(row, 'serviceId', '')
  961. this.$set(row, 'serviceName', '')
  962. }
  963. },
  964. // 选择销售政策获取政策条件列表
  965. async handlePolicy(e) {
  966. this.totalArr = []
  967. this.multipleSelections = []
  968. this.dataList = []
  969. this.popDataArr = []
  970. this.screenForm.saleTypeCode = ''
  971. const type = this.policyList.filter((k) => {
  972. return k.code === e
  973. })[0].type
  974. if (type == 'PROVISION') {
  975. // PROVISION 配提
  976. // 选择销售政策PolidcyId改变获取条件列表
  977. const { data } = await getPolicyConditionList({ policyId: e })
  978. this.factor = data
  979. this.pop = data[0].pop
  980. this.remark = data[0].remark || ''
  981. this.popArr = data[0].pop.split(':')
  982. if (this.policyId) {
  983. this.screenForm.policyId = this.policyId
  984. if (this.listItem) {
  985. this.policyConditionId = data[0].id
  986. }
  987. } else {
  988. this.screenForm.policyId = data[0].policyId
  989. this.policyConditionId = data[0].id
  990. }
  991. for (let i = 0; i < this.popArr.length; i++) {
  992. await this.getConditionList(this.policyConditionId, i + 1)
  993. }
  994. } else {
  995. // LIMIT 限量
  996. this.getMaterialTypeList('sProvision')
  997. }
  998. },
  999. hendleEdit(val, index) {
  1000. this.dialogVisible = false
  1001. // let params = {
  1002. // id: this.cid,
  1003. // theTime: this.mainForm.date,
  1004. // mainId: this.mainForm.type,
  1005. // mainName: this.mainForm.mainName,
  1006. // remark: this.mainForm.remark,
  1007. // type: 2,
  1008. // retailOrderItemList: this.goodsList,
  1009. // policyId: this.policyId,
  1010. // };
  1011. // editData(params).then((res) => {
  1012. // this.$successMsg("编辑成功");
  1013. // this.getDetail();
  1014. // });
  1015. },
  1016. // 获取条件相对应的比列
  1017. handleFactor(e) {
  1018. const data = this.factor.filter((k) => {
  1019. return k.id == e
  1020. })[0]
  1021. // // consloe(data, "kkkk");
  1022. this.pop = data.pop
  1023. this.popArr = data.pop.split(':')
  1024. this.screenForm.policyId = data.policyId
  1025. this.policyConditionId = data.id
  1026. },
  1027. // 引用销售政策搜索
  1028. async handlePolicyTypeList() {
  1029. if (this.popArr.length) {
  1030. this.popDataArr = []
  1031. this.dataList = []
  1032. for (let i = 0; i < this.popArr.length; i++) {
  1033. await this.getConditionList(this.policyConditionId, i + 1, false)
  1034. }
  1035. } else {
  1036. // sProvision = true
  1037. this.getMaterialTypeList('sProvision')
  1038. }
  1039. },
  1040. // 获取某一个比例下的数据 ,查询popType 当前 this.cusIndex+1
  1041. async getConditionList(policyConditionId, popType, fang) {
  1042. this.listLoading = true
  1043. const { data } = await getConditionList({
  1044. pageNum: this.currentPage,
  1045. pageSize: -1,
  1046. policyConditionId,
  1047. popType
  1048. })
  1049. if (!fang) {
  1050. this.poptotal['total' + popType] = data.total
  1051. this.popcun['cun' + popType] = 1
  1052. this.popfun['handleSizeChange' + popType] = (val, index) => {
  1053. this.popcun['cun' + index] = val
  1054. this.currentPage = 1
  1055. this.getConditionList(this.policyConditionId, index, true)
  1056. }
  1057. this.popfun['handleCurrentChange' + popType] = (val, index) => {
  1058. this.popcun['cun' + index] = val
  1059. this.getConditionList(this.policyConditionId, index, true)
  1060. }
  1061. }
  1062. const datas = data.records
  1063. if (this.listItem) {
  1064. for (let i = 0; i < this.goodsList.length; i++) {
  1065. for (let j = 0; j < datas.length; j++) {
  1066. if (datas[j].id == this.goodsList[i].policyMaterialId) {
  1067. this.$set(datas[j], 'disabled', true)
  1068. }
  1069. }
  1070. }
  1071. }
  1072. // this.total = data.total;
  1073. // console.log(this.goodsList,'4555');
  1074. if (this.goodsList.length) {
  1075. for (let p = 0; p < this.goodsList.length; p++) {
  1076. for (let q = 0; q < datas.length; q++) {
  1077. if (this.goodsList[p].id == datas[q].id) {
  1078. this.$set(datas[q], 'disabled', true)
  1079. }
  1080. }
  1081. }
  1082. }
  1083. for (let i = 0; i < data.records.length; i++) {
  1084. data.records[i].qty = 1
  1085. data.records[i].policyMaterialId = data.records[i].id
  1086. this.$set(
  1087. data.records[i],
  1088. 'zong',
  1089. data.records[i].qty * data.records[i].price
  1090. )
  1091. data.records[i].sums1 = ['price', 'qty', 'zong']
  1092. // this.$set(data.records[i],'userList',this.userList)
  1093. }
  1094. if (fang) {
  1095. this.popDataArr[popType] = datas
  1096. } else {
  1097. this.popDataArr.push(datas)
  1098. }
  1099. this.totalArr.push({
  1100. totalQty: 0,
  1101. totalPrice: 0,
  1102. totalAmount: 0
  1103. })
  1104. // this.$set(this.totalArr,[...this.totalArr])
  1105. this.listLoading = false
  1106. // consloe(this.popDataArr);
  1107. },
  1108. // 获取政策列表
  1109. getMaterialTypeList(val) {
  1110. this.listLoading2 = true
  1111. getMaterialTypeList({
  1112. pageNum: 1,
  1113. pageSize: -1,
  1114. policyId: this.screenForm.policyId,
  1115. saleTypeCode: this.screenForm.saleTypeCode,
  1116. [val]: true
  1117. }).then((res) => {
  1118. this.dataList = res.data.records
  1119. if (this.listItem) {
  1120. for (let i = 0; i < this.goodsList.length; i++) {
  1121. for (let j = 0; j < this.dataList.length; j++) {
  1122. if (this.dataList[j].id == this.goodsList[i].policyMaterialId) {
  1123. this.$set(this.dataList[i], 'disabled', true)
  1124. }
  1125. }
  1126. }
  1127. }
  1128. for (let i = 0; i < res.data.records.length; i++) {
  1129. this.$set(
  1130. res.data.records[i],
  1131. 'qty',
  1132. 1
  1133. )
  1134. res.data.records[i].sums1 = ['price', 'qty', 'zong']
  1135. res.data.records[i].userList = this.userList
  1136. res.data.records[i].policyMaterialId = res.data.records[i].id
  1137. for (let j = 0; j < this.goodsList.length; j++) {
  1138. if (this.goodsList[j].id == res.data.records[i].id) {
  1139. res.data.records[i].disabled = false
  1140. }
  1141. }
  1142. }
  1143. this.dataList = res.data.records
  1144. this.total = res.data.total
  1145. this.listLoading2 = false
  1146. this.popDataArr = []
  1147. this.popArr = []
  1148. // // consloe(this.dataList, "kkkk");
  1149. })
  1150. },
  1151. // 下一步获取某个政策条件比例数据
  1152. handleCondition() {
  1153. if (this.multipleSelection.length) {
  1154. this.cusIndex += 1
  1155. this.disabled = true
  1156. this.multipleData.push(this.multipleSelection)
  1157. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1158. } else {
  1159. this.$errorMsg('请选择')
  1160. }
  1161. // // consloe(this.cusIndex,'下');
  1162. },
  1163. // 上一步
  1164. handleShang() {
  1165. this.cusIndex == 0 ? (this.disabled = false) : ''
  1166. this.multipleData.splice(this.cusIndex, 1)
  1167. this.popDataArr.splice(this.cusIndex, 1)
  1168. this.cusIndex -= 1
  1169. // // consloe(this.cusIndex,'上');
  1170. },
  1171. /**
  1172. * 根据条件禁用行复选框
  1173. * 函数返回值为false则禁用选择(反之亦然)
  1174. * @param {Object} row - 行数据
  1175. * @param {String} index - 索引值
  1176. * @return Boolean
  1177. */
  1178. selectable: function(row, index) {
  1179. // row.disabled == undefined 才能被选中
  1180. if (row.disabled == undefined) {
  1181. return true
  1182. }
  1183. // 函数必须有返回值且是布尔值
  1184. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  1185. // 如果没有返回值则默认返回false(全部无法选中)
  1186. },
  1187. /**
  1188. * 根据条件禁用行复选框
  1189. * 函数返回值为false则禁用选择(反之亦然)
  1190. * @param {Object} row - 行数据
  1191. * @param {String} index - 索引值
  1192. * @return Boolean
  1193. */
  1194. selectable2: function(row, index) {
  1195. // row.disabled == undefined 才能被选中
  1196. if (row.disabled == undefined) {
  1197. return true
  1198. }
  1199. // 函数必须有返回值且是布尔值
  1200. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  1201. // 如果没有返回值则默认返回false(全部无法选中)
  1202. },
  1203. // 条件数据多选
  1204. handleSelectionChange(val, type, index) {
  1205. if (type === 1) {
  1206. this.type = 1
  1207. if (!this.multipleSelections.length) {
  1208. this.multipleSelections = new Array(index).fill([])
  1209. } else {
  1210. for (let i = 0; i < this.multipleSelections.length; i++) {
  1211. if (!this.multipleSelections[i] || !this.multipleSelections[i].length) {
  1212. this.multipleSelections[i] = []
  1213. }
  1214. }
  1215. }
  1216. this.$set(this.multipleSelections, index, val)
  1217. this.$set(this.totalArr, index, {
  1218. totalQty: 0,
  1219. totalPrice: 0,
  1220. totalAmount: 0
  1221. })
  1222. for (let j = 0; j < this.multipleSelections[index].length; j++) {
  1223. this.multipleSelections[index][j].fang = true
  1224. this.totalArr[index].totalQty +=
  1225. +this.multipleSelections[index][j].qty
  1226. this.totalArr[index].totalPrice +=
  1227. +this.multipleSelections[index][j].price
  1228. this.totalArr[index].totalAmount +=
  1229. +this.multipleSelections[index][j].price *
  1230. +this.multipleSelections[index][j].qty
  1231. }
  1232. // consloe(this.multipleSelections);
  1233. } else {
  1234. this.type = 2
  1235. this.multipleSelection = val
  1236. console.log(this.multipleSelection)
  1237. this.totalQty = this.totalPrice = this.totalAmount = 0
  1238. for (let i = 0; i < this.multipleSelection.length; i++) {
  1239. this.multipleSelection[i].fang = true
  1240. this.totalQty += +this.multipleSelection[i].qty
  1241. this.totalPrice += +this.multipleSelection[i].price
  1242. this.totalAmount +=
  1243. +this.multipleSelection[i].price *
  1244. +this.multipleSelection[i].qty
  1245. }
  1246. }
  1247. },
  1248. hanlePopData() {
  1249. console.log(this.multipleSelections)
  1250. this.multipleData.push(this.multipleSelection)
  1251. if (this.multipleData.length && this.multipleSelection.length) {
  1252. let arrData = []
  1253. for (let i = 0; i < this.multipleData.length; i++) {
  1254. if (this.multipleData[i].wallets && this.multipleData[i].wallets.length) {
  1255. this.$set(this.multipleData[i], 'customerWalletId', this.multipleData[i].wallets[0].customerWalletId)
  1256. this.$set(this.multipleData[i], 'serviceName', this.multipleData[i].wallets[0].serviceName)
  1257. this.$set(this.multipleData[i], 'serviceId', this.multipleData[i].wallets[0].serviceId)
  1258. }
  1259. arrData = [...arrData, ...this.multipleData[i]]
  1260. }
  1261. if (this.goodsList.length) {
  1262. this.goodsList = [...this.goodsList, ...arrData]
  1263. } else {
  1264. this.goodsList = arrData
  1265. }
  1266. if (this.dataList.length) {
  1267. for (let u = 0; u < this.goodsList.length; u++) {
  1268. this.goodsList[u].disabled = true
  1269. }
  1270. this.newDataList = this.multipleSelection
  1271. this.disabled = true
  1272. }
  1273. this.goodsList.forEach((item) => {
  1274. this.$set(item, 'status1', '')
  1275. this.$set(item, 'status2', '')
  1276. this.$set(item, 'userList', this.userList)
  1277. })
  1278. if (this.goodsList.length && this.goodsList[0].wallets.length) {
  1279. console.log(555555)
  1280. this.mainForm.k3ServiceName =
  1281. this.goodsList[0].wallets[0].serviceName || ''
  1282. this.mainForm.k3ServiceId =
  1283. this.goodsList[0].wallets[0].serviceId || ''
  1284. }
  1285. // if (this.goodsList.length>4) {
  1286. // this.newGoodsList = this.goodsList
  1287. // this.newGoodsList.length = 4
  1288. // }
  1289. this.cusIndex = 0
  1290. this.total = 0
  1291. this.popDataArr = []
  1292. this.multipleData = []
  1293. this.multipleSelection = []
  1294. this.policyId = this.screenForm.policyId
  1295. this.totalQty = this.totalPrice = this.totalAmount = 0
  1296. this.isShowDialog = false
  1297. this.$refs.singleTable.clearSelection()
  1298. // consloe(this.goodsList, "kkkk");
  1299. } else if (this.multipleSelections.length) {
  1300. let arrData = []
  1301. this.newMultipleSelections = this.multipleSelections
  1302. for (let i = 0; i < this.multipleSelections.length; i++) {
  1303. for (let j = 0; j < this.multipleSelections[i].length; j++) {
  1304. this.multipleSelections[i][j].disabled = true
  1305. if (this.multipleSelections[i][j].wallets.length) {
  1306. this.$set(this.multipleSelections[i][j], 'customerWalletId', this.multipleSelections[i][j].wallets[0].customerWalletId)
  1307. this.$set(this.multipleSelections[i][j], 'serviceName', this.multipleSelections[i][j].wallets[0].serviceName)
  1308. this.$set(this.multipleSelections[i][j], 'serviceId', this.multipleSelections[i][j].wallets[0].serviceId)
  1309. }
  1310. arrData = [...arrData, this.multipleSelections[i][j]]
  1311. }
  1312. }
  1313. if (this.goodsList.length) {
  1314. this.goodsList = [...this.goodsList, ...arrData]
  1315. } else {
  1316. this.goodsList = arrData
  1317. }
  1318. if (this.goodsList.length && this.goodsList[0].wallets.length) {
  1319. this.mainForm.k3ServiceName =
  1320. this.goodsList[0].wallets[0].serviceName || ''
  1321. this.mainForm.k3ServiceId =
  1322. this.goodsList[0].wallets[0].serviceId || ''
  1323. }
  1324. this.goodsList.forEach((item) => {
  1325. this.$set(item, 'status1', '')
  1326. this.$set(item, 'status2', '')
  1327. this.$set(item, 'userList', this.userList)
  1328. })
  1329. this.disabled = true
  1330. // this.popDataArr = [];
  1331. this.multipleData = []
  1332. this.multipleSelection = []
  1333. this.policyId = this.screenForm.policyId
  1334. this.totalQty = this.totalPrice = this.totalAmount = 0
  1335. this.isShowDialog = false
  1336. this.$refs.singleTable.forEach((k) => {
  1337. k.clearSelection()
  1338. })
  1339. // this.$refs.singleTable.clearSelection();
  1340. } else {
  1341. this.$errorMsg('请选择')
  1342. }
  1343. },
  1344. // 获取详情
  1345. getDetail() {
  1346. getUserList({
  1347. pageNum: 1,
  1348. pageSize: -1,
  1349. adminWebsitId: '',
  1350. isCustomer: 0,
  1351. roleId: '',
  1352. status: true,
  1353. userName: ''
  1354. }).then((res) => {
  1355. this.userList = res.data.records
  1356. getDetail({ id: this.listItem.id }).then(res => {
  1357. const data = res.data
  1358. this.mainForm.date = data.theTime
  1359. this.mainForm.type = data.mainId
  1360. this.mainForm.remark = data.remark
  1361. this.mainForm.policyId = data.policyId
  1362. this.policyId = data.policyId
  1363. this.mainForm.k3ServiceName = data.retailOrderItemList[0].wallets[0].serviceName
  1364. this.mainForm.k3ServiceId = data.retailOrderItemList[0].wallets[0].serviceId
  1365. data.retailOrderItemList.forEach((item) => {
  1366. item.status1 = ''
  1367. item.status2 = ''
  1368. this.$set(item, 'userList', this.userList)
  1369. item.wallets.forEach((k) => {
  1370. if (k.customerWalletId === data.customerWalletId) {
  1371. this.$set(item, 'serviceId', k.serviceId)
  1372. this.$set(item, 'serviceName', k.serviceName)
  1373. }
  1374. })
  1375. })
  1376. this.goodsList = data.retailOrderItemList
  1377. })
  1378. })
  1379. },
  1380. // 获取销售政策
  1381. getPolicyList() {
  1382. policyList({
  1383. pageNum: 1,
  1384. pageSize: -1,
  1385. status: true
  1386. }).then((res) => {
  1387. if (this.policyId) {
  1388. this.screenForm.policyId = this.policyId
  1389. this.disabled = true
  1390. } else {
  1391. this.screenForm.policyId = res.data.records[0].code
  1392. }
  1393. this.policyList = res.data.records
  1394. if (this.policyList.length) {
  1395. this.handlePolicy(this.screenForm.policyId)
  1396. }
  1397. })
  1398. },
  1399. // 获取销售类型
  1400. getTypeList() {
  1401. const params = {
  1402. pageNum: 1,
  1403. pageSize: -1,
  1404. saleCode: '',
  1405. saleName: '',
  1406. status: ''
  1407. }
  1408. typeList(params).then((res) => {
  1409. this.ztypeList = res.data.records
  1410. // // consloe(this.ztypeList, "type1111");
  1411. })
  1412. },
  1413. // 获取仓库列表
  1414. getWarehouseList() {
  1415. getWarehouseList({
  1416. pageNum: 1,
  1417. pageSize: -1
  1418. }).then((res) => {
  1419. this.warehouseList = res.data.records
  1420. })
  1421. },
  1422. // 获取限定机型
  1423. getpolicyTypeList() {
  1424. getpolicyTypeList({
  1425. pageNum: 1,
  1426. pageSize: 10,
  1427. policyId: this.screenForm.policyId,
  1428. saleTypeCode: this.screenForm.saleTypeCode
  1429. }).then((res) => {
  1430. for (let i = 0; i < res.data.records.length; i++) {
  1431. this.$set(
  1432. res.data.records[i],
  1433. 'qty',
  1434. 1
  1435. )
  1436. res.data.records[i].sums2 = ['price', 'qty', 'zong']
  1437. res.data.records[i].userList = this.userList
  1438. }
  1439. this.dataList = res.data.records
  1440. this.total = res.data.total
  1441. })
  1442. },
  1443. // 打开引用
  1444. handleShow() {
  1445. this.isShowDialog = true
  1446. this.getPolicyList()
  1447. },
  1448. // 获取钱包列表
  1449. getWalletList() {
  1450. getWalletList({
  1451. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  1452. type: 'COMMONLY'
  1453. }).then((res) => {
  1454. this.xjWalletList = res.data
  1455. })
  1456. getWalletList({
  1457. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  1458. type: 'REBATE'
  1459. }).then((res) => {
  1460. this.flWalletList = res.data
  1461. })
  1462. },
  1463. // 获取销售类型列表
  1464. getSalesTypeList() {
  1465. getSalesTypeList({
  1466. pageNum: 1,
  1467. pageSize: -1
  1468. }).then((res) => {
  1469. this.salesTypeList = res.data.records
  1470. })
  1471. },
  1472. getDictList() {
  1473. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then((res) => {
  1474. this.typeList = res.data
  1475. })
  1476. },
  1477. // 获取商品列表
  1478. getGoodsList() {
  1479. getGoodsList({
  1480. pageNum: this.currentPage,
  1481. pageSize: 10,
  1482. mainId: this.screenForm.type,
  1483. saleId: this.screenForm.salesType,
  1484. materialCode: this.screenForm.proNum,
  1485. materialName: this.screenForm.proName,
  1486. specification: this.screenForm.proModel,
  1487. price1: this.screenForm.price1,
  1488. price2: this.screenForm.price2
  1489. }).then((res) => {
  1490. const oldGoodsList = this.goodsList
  1491. const newGoodsList = res.data.records
  1492. for (let i = 0; i < oldGoodsList.length; i++) {
  1493. const oldItem = oldGoodsList[i]
  1494. for (let j = 0; j < newGoodsList.length; j++) {
  1495. const newItem = newGoodsList[j]
  1496. if (newItem.materialId === oldItem.materialId) {
  1497. newGoodsList[j].selected = true
  1498. break
  1499. }
  1500. }
  1501. }
  1502. res.data.records.forEach((item) => {
  1503. item.materialName = item.name
  1504. item.materialCode = item.number
  1505. item.saleTypeName = item.saleName
  1506. item.unit = item.baseUnit
  1507. item.price = item.batchPrice
  1508. item.tax = item.taxRate
  1509. item.isDirectTransfer = false
  1510. item.directTransferQty = ''
  1511. item.status1 = ''
  1512. item.status2 = ''
  1513. item.rebateAmount = ''
  1514. item.rebateRate = ''
  1515. item.productPriceId = item.id
  1516. })
  1517. this.leftGoodsList = res.data.records
  1518. this.listTotal = res.data.total
  1519. })
  1520. },
  1521. // 查询重复值并禁选
  1522. checkboxSelect(row, rowIndex) {
  1523. if (row.selected) {
  1524. return false // 禁用
  1525. } else {
  1526. return true // 不禁用
  1527. }
  1528. },
  1529. // 点击 选择商品
  1530. openDialog() {
  1531. this.getSalesTypeList()
  1532. this.getGoodsList()
  1533. this.isShowDialog = true
  1534. },
  1535. // 提交筛选表单
  1536. submitScreenForm() {
  1537. this.currentPage = 1
  1538. this.getGoodsList()
  1539. },
  1540. // 重置筛选表单
  1541. resetScreenForm() {
  1542. this.$refs.screenForm.resetFields()
  1543. this.currentPage = 1
  1544. this.getGoodsList()
  1545. },
  1546. // 关闭 弹窗
  1547. closeDialog() {
  1548. this.isShowDialog = false
  1549. this.popDataArr = []
  1550. },
  1551. // 删除
  1552. deleteGoods() {
  1553. const rightGoodsList = this.rightGoodsList
  1554. const rightSelection = this.rightSelection
  1555. for (let i = 0; i < rightGoodsList.length; i++) {
  1556. for (let j = 0; j < rightSelection.length; j++) {
  1557. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1558. this.rightGoodsList.splice(i, 1)
  1559. }
  1560. }
  1561. }
  1562. },
  1563. // 确定 添加产品
  1564. submitAddGoods() {
  1565. if (this.radio) {
  1566. const params = this.radio.split('&')
  1567. this.screenForm.policyId = params[1]
  1568. this.mainForm.policyId = params[1]
  1569. this.cusIndex += 1
  1570. getpolicyList({
  1571. materialId: params[2],
  1572. policyId: params[1]
  1573. }).then((res) => {
  1574. this.pop = res.data.pop
  1575. this.popArr = res.data.pop.split(':')
  1576. this.popArr.splice(0, 1)
  1577. for (let i = 0; i < this.popArr.length; i++) {
  1578. this.$set(this.radioObj, 'radio' + (i + 1), '')
  1579. }
  1580. this.step = this.cusIndex + 1
  1581. this.getConditionList(params[3], this.step)
  1582. })
  1583. } else {
  1584. this.$errorMsg('请选择')
  1585. }
  1586. },
  1587. // 更改每页数量
  1588. handleSizeChange(val) {
  1589. this.pageSize = val
  1590. this.currentPage = 1
  1591. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1592. },
  1593. // 更改当前页
  1594. handleCurrentChange(val) {
  1595. this.currentPage = val
  1596. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1597. },
  1598. // 更改列表当前页
  1599. handleTableCurrentChange(val) {
  1600. this.currentPage = val
  1601. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1602. },
  1603. handleClose() {
  1604. this.totalQty = this.totalPrice = this.totalAmount = 0
  1605. // this.dataList = [];
  1606. // this.popDataArr = [];
  1607. // this.screenForm.policyId = "";
  1608. // this.screenForm.saleTypeCode = "";
  1609. },
  1610. // 删除产品
  1611. deleteItem(index, id) {
  1612. this.goodsList.splice(index, 1)
  1613. // this.dataList
  1614. this.newDataList.splice(index, 1)
  1615. if (!this.goodsList.length) {
  1616. this.disabled = false
  1617. this.policyId = ''
  1618. this.mainForm.policyId = ''
  1619. }
  1620. // this.popDataArr.splice(index,1)
  1621. },
  1622. // 修改返利钱包
  1623. changeWallet(e, row) {
  1624. if (e){
  1625. const obj = row.rebateWallets.filter(k => {
  1626. return e === k.customerWalletId
  1627. })[0]
  1628. this.$set(row, 'rebateRate', (obj.rebateRate || 0))
  1629. }else{
  1630. this.$set(row, 'rebateRate', 0)
  1631. }
  1632. },
  1633. clearWallet(e){
  1634. console.log(e)
  1635. // const obj = row.rebateWallets.filter(k => {
  1636. // return e === k.customerWalletId
  1637. // })[0]
  1638. this.$set(row, 'rebateRate',0)
  1639. },
  1640. // 检查库存
  1641. checkStock() {
  1642. if (!this.warehouseValue) {
  1643. return this.$errorMsg('请选择仓库')
  1644. }
  1645. if (!this.goodsList) {
  1646. return this.$errorMsg('请添加货品')
  1647. }
  1648. const ids = []
  1649. this.goodsList.forEach((item) => {
  1650. ids.push(item.materialId)
  1651. })
  1652. checkStock({
  1653. correspondId: this.warehouseValue,
  1654. materialId: ids.join(',')
  1655. }).then((res) => {
  1656. if (res.data) {
  1657. this.goodsList.forEach((item, index) => {
  1658. item.status1 = res.data[index].allStockNum
  1659. item.status2 = res.data[index].stockNum
  1660. // // consloe(item.status1, item.status2);
  1661. })
  1662. }
  1663. })
  1664. },
  1665. status2Filter(item) {
  1666. if (
  1667. item.status2 === '' ||
  1668. item.status2 === null ||
  1669. item.status2 === undefined
  1670. ) { return '未检查' } else if (item.status2 >= item.qty) return '可用'
  1671. else return '短缺'
  1672. },
  1673. // 保存
  1674. clickSubmitForm() {
  1675. this.$refs.mainForm.validate((valid) => {
  1676. if (valid) {
  1677. // let mainName =
  1678. // this.typeList[
  1679. // findElem(this.typeList, "dictCode", this.mainForm.type)
  1680. // ].dictValue;
  1681. const params = {
  1682. theTime: this.mainForm.date,
  1683. k3ServiceId: this.mainForm.k3ServiceId,
  1684. k3ServiceName: this.mainForm.k3ServiceName,
  1685. remark: this.mainForm.remark,
  1686. type: 2, // 1:普通零售单,2:政策零售单
  1687. retailOrderItemList: this.goodsList,
  1688. policyId: this.policyId
  1689. }
  1690. console.log(params)
  1691. if (this.listItem) {
  1692. params.id = this.listItem.id
  1693. editData(params).then((res) => {
  1694. this.$successMsg('编辑成功')
  1695. this.goBack()
  1696. this.$parent.getList()
  1697. })
  1698. } else {
  1699. addData(params).then((res) => {
  1700. this.$successMsg('添加成功')
  1701. this.goBack()
  1702. this.$parent.getList()
  1703. })
  1704. }
  1705. }
  1706. })
  1707. }
  1708. }
  1709. }
  1710. </script>
  1711. <style scoped lang="scss">
  1712. .fr {
  1713. margin: 10px;
  1714. overflow: hidden;
  1715. }
  1716. .detail-container {
  1717. width: 100%;
  1718. height: 100%;
  1719. margin-bottom:80px;
  1720. ::v-deep .el-table__append-wrapper{
  1721. overflow: initial;
  1722. }
  1723. }
  1724. .table{
  1725. margin-top: 20px 0 0 0;
  1726. background-color: rgb(237 237 237);
  1727. }
  1728. .page-footer .footer.hideSidebar{
  1729. margin-left: 0;
  1730. width: 100%;
  1731. }
  1732. .mybox {
  1733. padding: 20px 0;
  1734. div:first-child {
  1735. flex: 0 0 55px;
  1736. }
  1737. div {
  1738. flex: 1 0 160px;
  1739. text-align: center;
  1740. }
  1741. }
  1742. .main-title {
  1743. display: flex;
  1744. justify-content: space-between;
  1745. align-items: center;
  1746. margin-top: 20px;
  1747. height: 60px;
  1748. border-bottom: 1px solid #dcdfe6;
  1749. margin-bottom: 20px;
  1750. .title {
  1751. font-size: 16px;
  1752. font-weight: 600;
  1753. padding-left: 10px;
  1754. }
  1755. }
  1756. .tables {
  1757. display: flex;
  1758. margin-top: 10px;
  1759. .table {
  1760. width: 45%;
  1761. }
  1762. .buttons {
  1763. display: flex;
  1764. flex-direction: column;
  1765. justify-content: center;
  1766. align-items: center;
  1767. padding: 0 10px;
  1768. button {
  1769. margin: 0;
  1770. margin-top: 10px;
  1771. }
  1772. }
  1773. }
  1774. .ellipsis {
  1775. overflow: hidden;
  1776. text-overflow: ellipsis;
  1777. white-space: nowrap;
  1778. }
  1779. </style>