retail_form.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header
  4. @back="goBack"
  5. :content="listItem ? '编辑' : '新增'"
  6. ></el-page-header>
  7. <div class="main-title">
  8. <div class="title">订单信息</div>
  9. </div>
  10. <el-form
  11. ref="mainForm"
  12. :model="mainForm"
  13. :rules="mainFormRules"
  14. label-width="120px"
  15. size="small"
  16. label-position="right"
  17. >
  18. <el-row :gutter="20">
  19. <!-- <el-col :xs="24" :sm="12" :lg="8">
  20. <el-form-item label="订单号" prop="id">
  21. <el-input
  22. v-model="mainForm.id"
  23. placeholder="订单号"
  24. readonly
  25. ></el-input>
  26. </el-form-item>
  27. </el-col> -->
  28. <el-col
  29. :xs="24"
  30. :sm="12"
  31. :lg="8"
  32. v-if="!listItem"
  33. @click.native="handleShow"
  34. >
  35. <el-form-item label="销售政策编号" prop="policyCode">
  36. <el-input
  37. v-model="mainForm.policyCode"
  38. placeholder="销售政策编号"
  39. readonly
  40. ></el-input>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :xs="24" :sm="12" :lg="8" v-else>
  44. <el-form-item label="销售政策编号" prop="policyCode">
  45. <el-input
  46. v-model="mainForm.policyCode"
  47. placeholder="销售政策编号"
  48. ></el-input>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  52. <el-form-item label="单据日期" prop="date">
  53. <el-date-picker
  54. v-model="mainForm.date"
  55. type="date"
  56. value-format="yyyy-MM-dd"
  57. style="width: 100%"
  58. placeholder="选择日期"
  59. >
  60. </el-date-picker>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :xs="24" :sm="12" :lg="8">
  64. <el-form-item label="产品大类" prop="type">
  65. <el-select
  66. v-model="mainForm.type"
  67. placeholder="选择产品大类"
  68. style="width: 100%"
  69. >
  70. <el-option
  71. v-for="item in typeList"
  72. :key="item.dictCode"
  73. :label="item.dictValue"
  74. :value="item.dictCode"
  75. ></el-option>
  76. </el-select>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :xs="24" :sm="16" :lg="16">
  80. <el-form-item label="备注" prop="remark">
  81. <el-input
  82. v-model="mainForm.remark"
  83. placeholder="请输入备注"
  84. ></el-input>
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <el-row :gutter="20">
  89. <!--
  90. <el-col :xs="24" :sm="12" :lg="8">
  91. <el-form-item label="销售政策" prop="id">
  92. <el-select
  93. v-model="mainForm.ztype"
  94. placeholder="选择销售政策"
  95. style="width: 100%"
  96. >
  97. <el-option
  98. v-for="item in ztypeList"
  99. :key="item.id"
  100. :label="item.saleName"
  101. :value="item.id"
  102. ></el-option>
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :xs="24" :sm="12" :lg="8">
  107. <el-form-item label="销售政策说明" prop="policyRemark">
  108. <el-input
  109. v-model="mainForm.policyRemark"
  110. placeholder="销售政策说明"
  111. ></el-input>
  112. </el-form-item>
  113. </el-col> -->
  114. </el-row>
  115. <!--
  116. <el-row :gutter="20">
  117. <el-col :xs="24" :sm="12" :lg="8">
  118. <el-form-item label="业务员" prop="serviceName">
  119. <el-input
  120. v-model="mainForm.serviceName"
  121. placeholder="订单号"
  122. ></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :xs="24" :sm="16" :lg="16">
  126. <el-form-item label="备注" prop="remark">
  127. <el-input
  128. v-model="mainForm.remark"
  129. placeholder="请输入备注"
  130. ></el-input>
  131. </el-form-item>
  132. </el-col>
  133. </el-row> -->
  134. </el-form>
  135. <div class="main-title">
  136. <div class="title">货品信息</div>
  137. <div v-if="!listItem">
  138. <el-select
  139. v-model="warehouseValue"
  140. placeholder="请选择发货仓库"
  141. size="small"
  142. style="margin-right: 10px"
  143. >
  144. <el-option
  145. :label="item.name"
  146. :value="item.id"
  147. v-for="(item, index) in warehouseList"
  148. :key="index"
  149. ></el-option>
  150. </el-select>
  151. <el-button
  152. type="primary"
  153. size="small"
  154. icon="el-icon-search"
  155. @click="checkStock"
  156. >检查库存</el-button
  157. >
  158. <el-divider direction="vertical"></el-divider>
  159. </div>
  160. </div>
  161. <div class="table" style="margin-top: 20px">
  162. <el-table
  163. :data="goodsList"
  164. element-loading-text="Loading"
  165. border
  166. fit
  167. highlight-current-row
  168. stripe
  169. max-height="400"
  170. >
  171. <el-table-column
  172. align="center"
  173. label="序号"
  174. type="index"
  175. width="50"
  176. ></el-table-column>
  177. <el-table-column
  178. align="center"
  179. label="销售类型"
  180. prop="saleTypeName"
  181. min-width="100"
  182. show-overflow-tooltip
  183. ></el-table-column>
  184. <el-table-column
  185. align="center"
  186. label="存货编码"
  187. prop="materialCode"
  188. min-width="100"
  189. show-overflow-tooltip
  190. ></el-table-column>
  191. <el-table-column
  192. align="center"
  193. label="产品名称"
  194. prop="materialName"
  195. min-width="160"
  196. show-overflow-tooltip
  197. ></el-table-column>
  198. <el-table-column
  199. align="center"
  200. label="规格型号"
  201. prop="specification"
  202. min-width="160"
  203. show-overflow-tooltip
  204. ></el-table-column>
  205. <el-table-column
  206. align="center"
  207. label="单位"
  208. prop="unit"
  209. min-width="100"
  210. show-overflow-tooltip
  211. ></el-table-column>
  212. <el-table-column
  213. align="center"
  214. label="单价"
  215. prop="price"
  216. min-width="100"
  217. show-overflow-tooltip
  218. ></el-table-column>
  219. <el-table-column
  220. align="center"
  221. label="数量"
  222. prop="qty"
  223. min-width="100"
  224. show-overflow-tooltip
  225. >
  226. <template slot-scope="scope">
  227. <el-input v-model="scope.row.qty" size="small"></el-input>
  228. </template>
  229. </el-table-column>
  230. <el-table-column
  231. align="center"
  232. label="订单金额"
  233. min-width="100"
  234. show-overflow-tooltip
  235. >
  236. <template slot-scope="scope">
  237. {{ scope.row.price * scope.row.qty }}
  238. </template>
  239. </el-table-column>
  240. <el-table-column
  241. align="center"
  242. label="返利钱包"
  243. prop="customerWalletId2"
  244. min-width="160"
  245. show-overflow-tooltip
  246. >
  247. <template slot-scope="scope">
  248. <el-select
  249. v-model="scope.row.customerWalletId2"
  250. placeholder="选择返利钱包"
  251. size="small"
  252. @change="changeWallet(scope.$index)"
  253. >
  254. <el-option label="不使用" value=""></el-option>
  255. <el-option
  256. v-for="item in flWalletList"
  257. :key="item.customerWalletId"
  258. :label="item.name"
  259. :value="item.customerWalletId"
  260. >
  261. </el-option>
  262. </el-select>
  263. </template>
  264. </el-table-column>
  265. <el-table-column
  266. align="center"
  267. label="返利金额"
  268. min-width="100"
  269. show-overflow-tooltip
  270. >
  271. <template slot-scope="scope">
  272. {{
  273. (scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) /
  274. 100 || 0
  275. }}
  276. </template>
  277. </el-table-column>
  278. <el-table-column
  279. align="center"
  280. label="格力折扣"
  281. min-width="100"
  282. show-overflow-tooltip
  283. >
  284. <template slot-scope="scope">
  285. {{ scope.row.qty * scope.row.discAmount }}
  286. </template>
  287. </el-table-column>
  288. <el-table-column
  289. align="center"
  290. label="现金钱包"
  291. prop="customerWalletId"
  292. min-width="160"
  293. show-overflow-tooltip
  294. >
  295. <template slot-scope="scope">
  296. <el-select
  297. v-model="scope.row.customerWalletId"
  298. placeholder="选择现金钱包"
  299. size="small"
  300. >
  301. <el-option label="不使用" value=""></el-option>
  302. <el-option
  303. v-for="item in comxjWalletList(scope.row.walletRelaList)"
  304. :key="item.customerWalletId"
  305. :label="item.name"
  306. :value="item.customerWalletId"
  307. >
  308. </el-option>
  309. </el-select>
  310. </template>
  311. </el-table-column>
  312. <el-table-column
  313. align="center"
  314. label="实付金额"
  315. prop="qty"
  316. min-width="100"
  317. show-overflow-tooltip
  318. >
  319. <template slot-scope="scope">
  320. {{
  321. (scope.row.price * scope.row.qty * 100 -
  322. ((scope.row.price *
  323. scope.row.qty *
  324. (scope.row.rebateRate * 100)) /
  325. 100) *
  326. 100 -
  327. ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) /
  328. 100 || 0
  329. }}
  330. </template>
  331. </el-table-column>
  332. <el-table-column
  333. align="center"
  334. label="是否直调"
  335. prop="isDirectTransfer"
  336. min-width="100"
  337. >
  338. <template slot-scope="scope">
  339. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  340. </template>
  341. </el-table-column>
  342. <el-table-column
  343. align="center"
  344. label="直调数量"
  345. prop="directTransferQty"
  346. min-width="100"
  347. >
  348. <template slot-scope="scope">
  349. <el-input
  350. v-model="scope.row.directTransferQty"
  351. size="small"
  352. ></el-input>
  353. </template>
  354. </el-table-column>
  355. <el-table-column
  356. align="center"
  357. label="备注"
  358. prop="remark"
  359. min-width="160"
  360. >
  361. <template slot-scope="scope">
  362. <el-input v-model="scope.row.remark" size="small"></el-input>
  363. </template>
  364. </el-table-column>
  365. <el-table-column
  366. align="center"
  367. label="税率"
  368. prop="tax"
  369. min-width="100"
  370. show-overflow-tooltip
  371. ></el-table-column>
  372. <el-table-column
  373. align="center"
  374. label="总仓库"
  375. prop="status1"
  376. min-width="100"
  377. show-overflow-tooltip
  378. v-if="!listItem"
  379. >
  380. <template slot-scope="scope">
  381. <div>{{ scope.row.status1 | status1Filter }}</div>
  382. </template>
  383. </el-table-column>
  384. <el-table-column
  385. align="center"
  386. label="仓库状态"
  387. prop="status2"
  388. min-width="100"
  389. show-overflow-tooltip
  390. v-if="!listItem"
  391. >
  392. <template slot-scope="scope">
  393. <div>{{ status2Filter(scope.row) }}</div>
  394. </template>
  395. </el-table-column>
  396. <el-table-column align="center" label="操作" width="100" fixed="right">
  397. <template slot-scope="scope">
  398. <el-button type="text" @click="deleteItem(scope.$index)"
  399. >删除</el-button
  400. >
  401. </template>
  402. </el-table-column>
  403. </el-table>
  404. </div>
  405. <div class="page-footer">
  406. <div class="footer" :class="classObj">
  407. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  408. <el-popconfirm
  409. title="确定关闭吗?"
  410. @onConfirm="goBack"
  411. style="margin-left: 10px"
  412. >
  413. <el-button slot="reference">关 闭</el-button>
  414. </el-popconfirm>
  415. </div>
  416. </div>
  417. <el-dialog
  418. :visible.sync="isShowDialog"
  419. @close="handleClose"
  420. width="80%"
  421. title="引用销售政策"
  422. >
  423. <template v-if="!cusIndex">
  424. <el-form
  425. :model="screenForm"
  426. ref="screenForm"
  427. label-width="120px"
  428. size="small"
  429. >
  430. <el-row :gutter="20">
  431. <el-col :xs="24" :sm="8" :lg="8">
  432. <el-form-item label="销售政策">
  433. <el-select
  434. v-model="screenForm.policyId"
  435. placeholder="选择销售政策"
  436. filterable
  437. style="width: 100%"
  438. >
  439. <el-option label="不使用" value=""></el-option>
  440. <el-option
  441. v-for="(item,index) in policyList"
  442. :key="index"
  443. :label="item.title"
  444. :value="item.code"
  445. ></el-option>
  446. </el-select> </el-form-item
  447. ></el-col>
  448. <el-col :xs="24" :sm="8" :lg="8">
  449. <el-form-item label="销售类型">
  450. <el-select
  451. v-model="screenForm.saleTypeCode"
  452. filterable
  453. placeholder="选择销售类型"
  454. style="width: 100%"
  455. >
  456. <el-option label="不使用" value=""></el-option>
  457. <el-option
  458. v-for="item in ztypeList"
  459. :key="item.id"
  460. :label="item.saleName"
  461. :value="item.saleCode"
  462. ></el-option>
  463. </el-select>
  464. </el-form-item>
  465. </el-col>
  466. <el-col :xs="24" :sm="8" :lg="8" class="tr">
  467. <el-button
  468. type="primary"
  469. size="small"
  470. @click="handlePolicyTypeList"
  471. >查询</el-button
  472. >
  473. </el-col>
  474. </el-row>
  475. </el-form>
  476. <el-row :gutter="20" style="margin: 10px 0"> 选择限定机型 </el-row>
  477. <el-table
  478. v-loading="listLoading"
  479. :data="dataList"
  480. element-loading-text="Loading"
  481. border
  482. fit
  483. highlight-current-row
  484. stripe
  485. >
  486. <el-table-column align="center" width="55"
  487. ><template slot-scope="scope">
  488. <el-radio
  489. v-model="radio"
  490. :label="
  491. scope.row.id +
  492. '&' +
  493. scope.row.policyId +
  494. '&' +
  495. scope.row.materialId +
  496. '&' +
  497. scope.row.policyConditionId
  498. "
  499. >{{ "" }}</el-radio
  500. >
  501. </template>
  502. </el-table-column>
  503. <template v-for="col in columns">
  504. <el-table-column
  505. v-if="col.num"
  506. align="center"
  507. :label="col.lable"
  508. :prop="col.prop"
  509. :min-width="col.widht"
  510. show-overflow-tooltip
  511. >
  512. <template slot-scope="scope">
  513. <el-input v-model="scope.row.qty" size="small"></el-input>
  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. </el-table-column>
  537. </template>
  538. </el-table>
  539. <!-- 分页 -->
  540. <div style="margin: 10px 0;">
  541. <el-pagination
  542. @size-change="handleSizeChange"
  543. @current-change="handleCurrentChange"
  544. :current-page="currentPage"
  545. :page-sizes="[10]"
  546. :page-size="10"
  547. layout="total, sizes, prev, pager, next, jumper"
  548. :total="dataList.length"
  549. >
  550. </el-pagination>
  551. </div>
  552. <span slot="footer" class="dialog-footer">
  553. <el-button type="primary" @click="submitAddGoods">下一步</el-button>
  554. </span>
  555. </template>
  556. <template v-else>
  557. <el-form
  558. :model="screenForm"
  559. ref="screenForm"
  560. label-width="120px"
  561. size="small"
  562. >
  563. <el-row :gutter="20">
  564. <el-col :xs="24" :sm="8" :lg="8">
  565. <el-form-item label="销售政策">
  566. <el-select
  567. v-model="screenForm.policyId"
  568. placeholder="选择销售政策"
  569. filterable
  570. style="width: 100%"
  571. >
  572. <el-option
  573. v-for="(item,index) in policyList"
  574. :key="index"
  575. :label="item.title"
  576. :value="item.code"
  577. ></el-option>
  578. </el-select>
  579. </el-form-item>
  580. </el-col>
  581. <el-col :xs="24" :sm="8" :lg="8">
  582. <el-form-item label="销售类型">
  583. <el-select
  584. filterable
  585. v-model="screenForm.saleTypeCode"
  586. placeholder="选择销售类型"
  587. style="width: 100%"
  588. >
  589. <el-option label="不使用" value=""></el-option>
  590. <el-option
  591. v-for="item in ztypeList"
  592. :key="item.id"
  593. :label="item.saleName"
  594. :value="item.saleCode"
  595. ></el-option>
  596. </el-select>
  597. </el-form-item>
  598. </el-col>
  599. <el-col :xs="24" :sm="8" :lg="8" class="tr">
  600. <el-button type="primary" size="small">查询</el-button>
  601. </el-col>
  602. </el-row>
  603. </el-form>
  604. <el-row type="flex" :gutter="20">
  605. <el-col style="margin: 10px 0">已选择限定机型</el-col>
  606. <el-col></el-col>
  607. <el-col></el-col>
  608. <el-col></el-col>
  609. <el-col></el-col>
  610. </el-row>
  611. <template v-for="(item, index) in popArr">
  612. <el-table
  613. v-if="index + 1 == cusIndex"
  614. v-loading="listLoading"
  615. :data="popDataArr[cusIndex - 1]"
  616. element-loading-text="Loading"
  617. border
  618. fit
  619. highlight-current-row
  620. stripe
  621. >
  622. <el-table-column align="center" width="55"
  623. ><template slot-scope="scope">
  624. <el-radio
  625. v-model="radioObj['radio' + cusIndex]"
  626. :label="scope.row.id"
  627. >{{ "" }}</el-radio
  628. >
  629. </template>
  630. </el-table-column>
  631. <template v-for="col in columns">
  632. <el-table-column
  633. v-if="col.num"
  634. align="center"
  635. :label="col.lable"
  636. :prop="col.prop"
  637. :min-width="col.widht"
  638. show-overflow-tooltip
  639. >
  640. <template slot-scope="scope">
  641. <el-input v-model="scope.row.qty" size="small"></el-input>
  642. </template>
  643. </el-table-column>
  644. <el-table-column
  645. v-else-if="col.jie"
  646. align="center"
  647. :label="col.lable"
  648. :prop="col.prop"
  649. :min-width="col.widht"
  650. show-overflow-tooltip
  651. >
  652. <template slot-scope="scope">
  653. {{ scope.row.qty * scope.row.price || 0 }}
  654. </template>
  655. </el-table-column>
  656. <el-table-column
  657. v-else
  658. align="center"
  659. :label="col.lable"
  660. :prop="col.prop"
  661. :min-width="col.widht"
  662. show-overflow-tooltip
  663. >
  664. </el-table-column>
  665. </template>
  666. </el-table>
  667. <!-- 分页 -->
  668. <div style="margin: 10px 0;">
  669. <el-pagination
  670. @size-change="handleSizeChange"
  671. @current-change="handleCurrentChange"
  672. :current-page="currentPage"
  673. :page-sizes="[10]"
  674. :page-size="10"
  675. layout="total, sizes, prev, pager, next, jumper"
  676. :total="popDataArr[cusIndex - 1].length"
  677. >
  678. </el-pagination>
  679. </div>
  680. </template>
  681. <span slot="footer" class="dialog-footer">
  682. <el-button type="primary" @click="cusIndex -= 1">上一步</el-button>
  683. <el-button
  684. type="primary"
  685. @click="handleCondition()"
  686. v-if="popArr.length != cusIndex"
  687. >下一步</el-button
  688. >
  689. <el-button
  690. type="primary"
  691. @click="hanlePopData"
  692. v-if="popArr.length == cusIndex"
  693. >完成</el-button
  694. >
  695. </span>
  696. </template>
  697. </el-dialog>
  698. </div>
  699. </template>
  700. <script>
  701. import {
  702. getDetail,
  703. addData,
  704. editData,
  705. getSalesTypeList,
  706. getGoodsList,
  707. getWalletList,
  708. getWarehouseList,
  709. policyList,
  710. checkStock,
  711. typeList,
  712. getpolicyList,
  713. getConditionList,
  714. getConditionDetail,
  715. getpolicyTypeList,
  716. } from "@/api/supply/policy";
  717. import { getDictList } from "@/api/common";
  718. import { findElem } from "@/utils/util";
  719. export default {
  720. name: "RetailForm",
  721. componentName: "RetailForm",
  722. props: ["listItem"],
  723. filters: {
  724. status1Filter(val) {
  725. if (val === "" || val === null || val === undefined) return "未检查";
  726. else if (val === 0) return "无货";
  727. else if (val > 0 && val <= 30) return val;
  728. else if (val > 30 && val <= 1000) return "有货";
  729. else if (val > 1000) return "充足";
  730. },
  731. },
  732. data() {
  733. return {
  734. tableData: [
  735. ],
  736. currentPage: 1, // 当前页码
  737. pageSize: 10, // 每页数量
  738. listTotal: 0, // 列表总数
  739. cusIndex: 0,
  740. radio: "",
  741. pop: "",
  742. popArr: [],
  743. mainForm: {
  744. id: "",
  745. date: "",
  746. type: "",
  747. ztype: "",
  748. remark: "",
  749. policyCode: "",
  750. policyRemark: "",
  751. policyId: "",
  752. },
  753. mainFormRules: {
  754. date: [
  755. { required: true, message: "请选择单据日期", trigger: "change" },
  756. ],
  757. type: [{ required: true, message: "请选择品类", trigger: "change" }],
  758. },
  759. goodsList: [],
  760. warehouseList: [],
  761. warehouseValue: "",
  762. isShowDialog: false,
  763. screenForm: {
  764. policyId: "",
  765. saleTypeCode: "",
  766. },
  767. currentPage: 1,
  768. listTotal: 0,
  769. salesTypeList: [],
  770. typeList: [],
  771. ztypeList: [],
  772. leftGoodsList: [],
  773. rightGoodsList: [],
  774. leftSelection: [],
  775. rightSelection: [],
  776. policyList: [],
  777. xjWalletList: [],
  778. flWalletList: [],
  779. dataList: [],
  780. columns: [
  781. {
  782. prop: "saleTypeName",
  783. lable: "销售类型",
  784. widht: 160,
  785. },
  786. {
  787. prop: "materialName",
  788. lable: "货品名称",
  789. widht: 160,
  790. },
  791. {
  792. prop: "specification",
  793. lable: "规格型号",
  794. widht: 160,
  795. },
  796. {
  797. prop: "qty",
  798. lable: "数量",
  799. widht: 160,
  800. num: true,
  801. },
  802. {
  803. prop: "price",
  804. lable: "单价",
  805. widht: 160,
  806. },
  807. {
  808. prop: "zong",
  809. lable: "金额",
  810. jie: true,
  811. },
  812. ],
  813. listLoading: false,
  814. popDataArr: [],
  815. radioObj: {},
  816. step:0,
  817. };
  818. },
  819. computed: {
  820. sidebar() {
  821. return this.$store.state.app.sidebar;
  822. },
  823. classObj() {
  824. return {
  825. hideSidebar: !this.sidebar.opened,
  826. openSidebar: this.sidebar.opened,
  827. };
  828. },
  829. comxjWalletList() {
  830. return (c) => {
  831. console.log(c);
  832. const walle = [];
  833. const ovalVall = c == undefined || !c.length ? [] : c;
  834. for (let i = 0; i < this.xjWalletList.length; i++) {
  835. for (let j = 0; j < ovalVall.length; j++) {
  836. if (this.xjWalletList[i].walletRebateId == ovalVall[j].walletId) {
  837. walle.push(this.xjWalletList[i]);
  838. }
  839. }
  840. }
  841. return walle;
  842. };
  843. },
  844. },
  845. created() {
  846. this.getDictList();
  847. this.getWalletList();
  848. this.getWarehouseList();
  849. this.getPolicyList();
  850. this.getTypeList();
  851. if (this.listItem) {
  852. this.getDetail();
  853. }
  854. },
  855. methods: {
  856. // 返回列表
  857. goBack() {
  858. this.$emit("backListFormDetail");
  859. },
  860. // 获取详情
  861. getDetail() {
  862. getDetail({ id: this.listItem.id }).then((res) => {
  863. let data = res.data;
  864. this.mainForm.date = data.theTime;
  865. this.mainForm.type = data.mainId;
  866. this.mainForm.remark = data.remark;
  867. data.retailOrderItemList.forEach((item) => {
  868. item.status1 = "";
  869. item.status2 = "";
  870. });
  871. this.goodsList = data.retailOrderItemList;
  872. });
  873. },
  874. getPolicyList() {
  875. policyList({
  876. pageNum: 1,
  877. pageSize: -1,
  878. }).then((res) => {
  879. console.log(res, "tyep");
  880. this.policyList = res.data.records;
  881. });
  882. },
  883. getTypeList() {
  884. const params = {
  885. pageNum: 1,
  886. pageSize: -1,
  887. saleCode: "",
  888. saleName: "",
  889. status: "",
  890. };
  891. typeList(params).then((res) => {
  892. this.ztypeList = res.data.records;
  893. console.log(this.ztypeList,'type1111');
  894. });
  895. },
  896. handleSelectiontAllChange(e) {
  897. console.log(e);
  898. },
  899. handleSelectionChange(e) {
  900. console.log(e);
  901. },
  902. // 获取仓库列表
  903. getWarehouseList() {
  904. getWarehouseList({
  905. pageNum: 1,
  906. pageSize: -1,
  907. }).then((res) => {
  908. this.warehouseList = res.data.records;
  909. });
  910. },
  911. // 获取限定机型
  912. getpolicyTypeList() {
  913. getpolicyTypeList({
  914. pageNum: 1,
  915. pageSize: 10,
  916. policyId: this.screenForm.policyId,
  917. saleTypeCode: this.screenForm.saleTypeCode,
  918. }).then((res) => {
  919. for (let i = 0; i < res.data.records.length; i++) {
  920. res.data.records[i].qty = 1;
  921. }
  922. this.dataList = res.data.records;
  923. });
  924. },
  925. getMaterialTypeList() {
  926. getMaterialTypeList({
  927. pageNum: 1,
  928. pageSize: 10,
  929. policyId: this.screenForm.policyId,
  930. saleTypeCode: this.screenForm.saleTypeCode,
  931. }).then((res) => {
  932. });
  933. },
  934. handlePolicyTypeList() {
  935. this.getpolicyTypeList();
  936. },
  937. handleShow() {
  938. this.isShowDialog = true;
  939. },
  940. // 获取钱包列表
  941. getWalletList() {
  942. getWalletList({
  943. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  944. type: "COMMONLY",
  945. }).then((res) => {
  946. this.xjWalletList = res.data;
  947. console.log(res.data, "xxxxx");
  948. });
  949. getWalletList({
  950. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  951. type: "REBATE",
  952. }).then((res) => {
  953. this.flWalletList = res.data;
  954. console.log(this.flWalletList, "xxccc");
  955. });
  956. },
  957. // 获取销售类型列表
  958. getSalesTypeList() {
  959. getSalesTypeList({
  960. pageNum: 1,
  961. pageSize: -1,
  962. }).then((res) => {
  963. this.salesTypeList = res.data.records;
  964. });
  965. },
  966. getDictList() {
  967. getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  968. this.typeList = res.data;
  969. });
  970. },
  971. // 获取商品列表
  972. getGoodsList() {
  973. getGoodsList({
  974. pageNum: this.currentPage,
  975. pageSize: 10,
  976. mainId: this.screenForm.type,
  977. saleId: this.screenForm.salesType,
  978. materialCode: this.screenForm.proNum,
  979. materialName: this.screenForm.proName,
  980. specification: this.screenForm.proModel,
  981. price1: this.screenForm.price1,
  982. price2: this.screenForm.price2,
  983. }).then((res) => {
  984. let oldGoodsList = this.goodsList;
  985. let newGoodsList = res.data.records;
  986. for (let i = 0; i < oldGoodsList.length; i++) {
  987. let oldItem = oldGoodsList[i];
  988. for (let j = 0; j < newGoodsList.length; j++) {
  989. let newItem = newGoodsList[j];
  990. if (newItem.materialId === oldItem.materialId) {
  991. newGoodsList[j].selected = true;
  992. break;
  993. }
  994. }
  995. }
  996. res.data.records.forEach((item) => {
  997. item.materialName = item.name;
  998. item.materialCode = item.number;
  999. item.saleTypeName = item.saleName;
  1000. item.unit = item.baseUnit;
  1001. item.price = item.batchPrice;
  1002. item.tax = item.taxRate;
  1003. item.isDirectTransfer = false;
  1004. item.directTransferQty = "";
  1005. item.status1 = "";
  1006. item.status2 = "";
  1007. item.rebateAmount = "";
  1008. item.rebateRate = "";
  1009. item.productPriceId = item.id;
  1010. });
  1011. this.leftGoodsList = res.data.records;
  1012. this.listTotal = res.data.total;
  1013. });
  1014. },
  1015. // 查询重复值并禁选
  1016. checkboxSelect(row, rowIndex) {
  1017. if (row.selected) {
  1018. return false; // 禁用
  1019. } else {
  1020. return true; // 不禁用
  1021. }
  1022. },
  1023. // 点击 选择商品
  1024. openDialog() {
  1025. this.getSalesTypeList();
  1026. this.getGoodsList();
  1027. this.isShowDialog = true;
  1028. },
  1029. // 提交筛选表单
  1030. submitScreenForm() {
  1031. this.currentPage = 1;
  1032. this.getGoodsList();
  1033. },
  1034. // 重置筛选表单
  1035. resetScreenForm() {
  1036. this.$refs.screenForm.resetFields();
  1037. this.currentPage = 1;
  1038. this.getGoodsList();
  1039. },
  1040. // 更改列表当前页
  1041. handleTableCurrentChange(val) {
  1042. this.currentPage = val;
  1043. this.getGoodsList();
  1044. },
  1045. // 关闭 弹窗
  1046. closeDialog() {
  1047. this.isShowDialog = false;
  1048. },
  1049. // 删除
  1050. deleteGoods() {
  1051. let rightGoodsList = this.rightGoodsList;
  1052. let rightSelection = this.rightSelection;
  1053. for (let i = 0; i < rightGoodsList.length; i++) {
  1054. for (let j = 0; j < rightSelection.length; j++) {
  1055. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1056. this.rightGoodsList.splice(i, 1);
  1057. }
  1058. }
  1059. }
  1060. },
  1061. handleCondition() {
  1062. if (Object.values(this.radioObj)[this.cusIndex - 1] !== "") {
  1063. this.popArr.length >= this.cusIndex ? (this.cusIndex += 1) : "";
  1064. const params = this.radio.split("&");
  1065. this.step = this.cusIndex+1
  1066. this.getConditionList(params[3], this.step);
  1067. return;
  1068. } else {
  1069. this.$errorMsg("请选择");
  1070. }
  1071. },
  1072. // 确定 添加产品
  1073. submitAddGoods() {
  1074. if (this.radio) {
  1075. const params = this.radio.split("&");
  1076. this.screenForm.policyId = params[1];
  1077. this.mainForm.policyId = params[1];
  1078. this.cusIndex += 1;
  1079. getpolicyList({
  1080. materialId: params[2],
  1081. policyId: params[1],
  1082. }).then((res) => {
  1083. this.pop = res.data.pop;
  1084. this.popArr = res.data.pop.split(":");
  1085. this.popArr.splice(0, 1);
  1086. console.log;
  1087. for (let i = 0; i < this.popArr.length; i++) {
  1088. this.$set(this.radioObj, "radio" + (i + 1), "");
  1089. }
  1090. this.step = this.cusIndex+1
  1091. this.getConditionList(params[3], this.step );
  1092. });
  1093. } else {
  1094. this.$errorMsg("请选择");
  1095. }
  1096. },
  1097. // 更改每页数量
  1098. handleSizeChange(val) {
  1099. this.pageSize = val;
  1100. this.currentPage = 1;
  1101. const params = this.radio.split("&");
  1102. this.step = this.cusIndex+1
  1103. this.getConditionList(params[3], this.step);
  1104. },
  1105. // 更改当前页
  1106. handleCurrentChange(val) {
  1107. this.currentPage = val;
  1108. const params = this.radio.split("&");
  1109. this.step = this.cusIndex+1
  1110. this.getConditionList(params[3], this.step);
  1111. },
  1112. getConditionList(policyConditionId, popType) {
  1113. getConditionList({
  1114. pageNum: this.currentPage,
  1115. pageSize:this.pageSize,
  1116. policyConditionId,
  1117. popType,
  1118. }).then((res) => {
  1119. for (let i = 0; i < res.data.records.length; i++) {
  1120. res.data.records[i].qty = 1;
  1121. }
  1122. if (this.popDataArr.length) {
  1123. this.popDataArr.splice(this.cusIndex - 1, 1);
  1124. }
  1125. if (this.cusIndex == 0) {
  1126. this.popDataArr = [];
  1127. }
  1128. this.popDataArr.push(res.data.records);
  1129. // console.log(this.popDataArr, "[]", this.radioObj);
  1130. });
  1131. },
  1132. hanlePopData() {
  1133. if (!Object.values(this.radioObj).includes("")) {
  1134. let arrData = [];
  1135. for (let i = 0; i < this.popDataArr.length; i++) {
  1136. arrData = [...arrData, ...this.popDataArr[i]];
  1137. }
  1138. for (let j = 0; j < arrData.length; j++) {
  1139. for (const key in this.radioObj) {
  1140. if (arrData[j].id == this.radioObj[key]) {
  1141. this.goodsList = [...this.goodsList, arrData[j]];
  1142. }
  1143. }
  1144. }
  1145. const params = this.radio.split("&");
  1146. let arr = [];
  1147. for (let k = 0; k < this.dataList.length; k++) {
  1148. if (this.dataList[k].policyId == params[1]) {
  1149. arr = [this.dataList[k]];
  1150. }
  1151. }
  1152. this.goodsList = [...arr, ...this.goodsList];
  1153. this.goodsList.forEach((item) => {
  1154. this.$set(item, "status1", "");
  1155. this.$set(item, "status2", "");
  1156. });
  1157. this.cusIndex = 0;
  1158. this.radio = "";
  1159. this.dataList = [];
  1160. this.screenForm.policyId = "";
  1161. this.screenForm.saleTypeCode = "";
  1162. this.isShowDialog = false;
  1163. } else {
  1164. this.$errorMsg("请选择");
  1165. }
  1166. },
  1167. handleClose() {
  1168. this.cusIndex = 0;
  1169. this.radio = "";
  1170. this.dataList = [];
  1171. this.screenForm.policyId = "";
  1172. this.screenForm.saleTypeCode = "";
  1173. },
  1174. // 删除产品
  1175. deleteItem(index) {
  1176. this.goodsList.splice(index, 1);
  1177. },
  1178. // 修改返利钱包
  1179. changeWallet(index) {
  1180. if (this.goodsList[index].customerWalletId2) {
  1181. let obj = this.flWalletList.find(
  1182. (o) => o.customerWalletId == this.goodsList[index].customerWalletId2
  1183. );
  1184. this.goodsList[index].rebateRate = obj.rebateRate;
  1185. } else {
  1186. this.goodsList[index].rebateRate = "";
  1187. }
  1188. },
  1189. // 检查库存
  1190. checkStock() {
  1191. if (!this.warehouseValue) {
  1192. return this.$errorMsg("请选择仓库");
  1193. }
  1194. if (!this.goodsList) {
  1195. return this.$errorMsg("请添加货品");
  1196. }
  1197. let ids = [];
  1198. this.goodsList.forEach((item) => {
  1199. ids.push(item.materialId);
  1200. });
  1201. checkStock({
  1202. correspondId: this.warehouseValue,
  1203. materialId: ids.join(","),
  1204. }).then((res) => {
  1205. if (res.data) {
  1206. this.goodsList.forEach((item, index) => {
  1207. item.status1 = res.data[index].allStockNum;
  1208. item.status2 = res.data[index].stockNum;
  1209. console.log(item.status1, item.status2);
  1210. });
  1211. }
  1212. });
  1213. },
  1214. status2Filter(item) {
  1215. if (
  1216. item.status2 === "" ||
  1217. item.status2 === null ||
  1218. item.status2 === undefined
  1219. )
  1220. return "未检查";
  1221. else if (item.status2 >= item.qty) return "可用";
  1222. else return "短缺";
  1223. },
  1224. // 保存
  1225. clickSubmitForm() {
  1226. this.$refs.mainForm.validate((valid) => {
  1227. if (valid) {
  1228. // for (let i = 0; i < this.goodsList.length; i++) {
  1229. // console.log(this.goodsList[i].customerWalletId, 45454554);
  1230. // if (!this.goodsList[i].customerWalletId) {
  1231. // this.$errorMsg("请选择现金钱包");
  1232. // return;
  1233. // }
  1234. // }
  1235. let mainName =
  1236. this.typeList[
  1237. findElem(this.typeList, "dictCode", this.mainForm.type)
  1238. ].dictValue;
  1239. let params = {
  1240. theTime: this.mainForm.date + " 00:00:00",
  1241. mainId: this.mainForm.type,
  1242. mainName,
  1243. remark: this.mainForm.remark,
  1244. type: 2, // 1:普通零售单,2:政策零售单
  1245. retailOrderItemList: this.goodsList,
  1246. policyId: this.screenForm.policyId,
  1247. };
  1248. if (this.listItem) {
  1249. params.id = this.listItem.id;
  1250. editData(params).then((res) => {
  1251. this.$successMsg("编辑成功");
  1252. this.goBack();
  1253. this.$parent.getList();
  1254. });
  1255. } else {
  1256. addData(params).then((res) => {
  1257. this.$successMsg("添加成功");
  1258. this.goBack();
  1259. this.$parent.getList();
  1260. });
  1261. }
  1262. }
  1263. });
  1264. },
  1265. },
  1266. };
  1267. </script>
  1268. <style scoped lang="scss">
  1269. .fr{
  1270. margin: 10px;
  1271. overflow: hidden;
  1272. }
  1273. .detail-container {
  1274. width: 100%;
  1275. height: 100%;
  1276. }
  1277. .main-title {
  1278. display: flex;
  1279. justify-content: space-between;
  1280. align-items: center;
  1281. margin-top: 20px;
  1282. height: 60px;
  1283. border-bottom: 1px solid #dcdfe6;
  1284. margin-bottom: 20px;
  1285. .title {
  1286. font-size: 16px;
  1287. font-weight: 600;
  1288. padding-left: 10px;
  1289. }
  1290. }
  1291. .tables {
  1292. display: flex;
  1293. margin-top: 10px;
  1294. .table {
  1295. width: 45%;
  1296. }
  1297. .buttons {
  1298. display: flex;
  1299. flex-direction: column;
  1300. justify-content: center;
  1301. align-items: center;
  1302. padding: 0 10px;
  1303. button {
  1304. margin: 0;
  1305. margin-top: 10px;
  1306. }
  1307. }
  1308. }
  1309. </style>