retail_form2.vue 39 KB

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