retail_form.vue 53 KB

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