retail_form.vue 53 KB

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