retail_form.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392
  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="materialNumber"
  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
  440. v-for="(item, index) in policyList"
  441. :key="index"
  442. :label="item.title"
  443. :value="item.code"
  444. ></el-option>
  445. </el-select> </el-form-item
  446. ></el-col>
  447. <el-col :xs="24" :sm="8" :lg="8">
  448. <el-form-item label="销售类型">
  449. <el-select
  450. v-model="screenForm.saleTypeCode"
  451. filterable
  452. placeholder="选择销售类型"
  453. style="width: 100%"
  454. >
  455. <el-option label="全部" value=""></el-option>
  456. <el-option
  457. v-for="item in ztypeList"
  458. :key="item.id"
  459. :label="item.saleName"
  460. :value="item.saleCode"
  461. ></el-option>
  462. </el-select>
  463. </el-form-item>
  464. </el-col>
  465. <el-col :xs="24" :sm="8" :lg="8" class="tr">
  466. <el-button
  467. type="primary"
  468. size="small"
  469. @click="handlePolicyTypeList"
  470. >查询</el-button
  471. >
  472. </el-col>
  473. </el-row>
  474. </el-form>
  475. <el-row :gutter="20" style="margin: 10px 0"> 选择限定机型 </el-row>
  476. <el-table
  477. v-loading="listLoading"
  478. :data="dataList"
  479. element-loading-text="Loading"
  480. border
  481. fit
  482. highlight-current-row
  483. stripe
  484. >
  485. <el-table-column align="center" width="55"
  486. ><template slot-scope="scope">
  487. <el-radio
  488. v-model="radio"
  489. :label="
  490. scope.row.id +
  491. '&' +
  492. scope.row.policyId +
  493. '&' +
  494. scope.row.materialId +
  495. '&' +
  496. scope.row.policyConditionId
  497. "
  498. >{{ "" }}</el-radio
  499. >
  500. </template>
  501. </el-table-column>
  502. <template v-for="col in columns">
  503. <el-table-column
  504. v-if="col.num"
  505. align="center"
  506. :label="col.lable"
  507. :prop="col.prop"
  508. :min-width="col.widht"
  509. show-overflow-tooltip
  510. >
  511. <template slot-scope="scope">
  512. <el-input v-model="scope.row.qty" size="small"></el-input>
  513. </template>
  514. </el-table-column>
  515. <el-table-column
  516. v-else-if="col.jie"
  517. align="center"
  518. :label="col.lable"
  519. :prop="col.prop"
  520. :min-width="col.widht"
  521. show-overflow-tooltip
  522. >
  523. <template slot-scope="scope">
  524. {{ scope.row.qty * scope.row.price || 0 }}
  525. </template>
  526. </el-table-column>
  527. <el-table-column
  528. v-else
  529. align="center"
  530. :label="col.lable"
  531. :prop="col.prop"
  532. :min-width="col.widht"
  533. show-overflow-tooltip
  534. >
  535. </el-table-column>
  536. </template>
  537. </el-table>
  538. <!-- 分页 -->
  539. <div style="margin: 10px 0">
  540. <el-pagination
  541. @size-change="handleSizeChange"
  542. @current-change="handleCurrentChange"
  543. :current-page="currentPage"
  544. :page-sizes="[10]"
  545. :page-size="10"
  546. layout="total, sizes, prev, pager, next, jumper"
  547. :total="dataList.length"
  548. >
  549. </el-pagination>
  550. </div>
  551. <span slot="footer" class="dialog-footer">
  552. <el-button type="primary" @click="submitAddGoods">下一步</el-button>
  553. </span>
  554. </template>
  555. <template v-else>
  556. <el-form
  557. :model="screenForm"
  558. ref="screenForm"
  559. label-width="120px"
  560. size="small"
  561. >
  562. <el-row :gutter="20">
  563. <el-col :xs="24" :sm="8" :lg="8">
  564. <el-form-item label="销售政策">
  565. <el-select
  566. disabled
  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
  601. type="primary"
  602. size="small"
  603. @click="handlePolicyTypeList"
  604. >查询</el-button
  605. >
  606. </el-col>
  607. </el-row>
  608. </el-form>
  609. <el-row type="flex" :gutter="20" style="margin: 10px 0">
  610. <el-col>已选择限定机型</el-col>
  611. <el-col>{{ comText("mainName") }}</el-col>
  612. <el-col>{{ comText("specification") }}</el-col>
  613. <el-col></el-col>
  614. <el-col style="text-align: right">配提比例:{{ pop }}</el-col>
  615. </el-row>
  616. <template v-for="(item, index) in popArr">
  617. <el-table
  618. v-if="index + 1 == cusIndex"
  619. v-loading="listLoading"
  620. :data="popDataArr[cusIndex - 1]"
  621. element-loading-text="Loading"
  622. border
  623. fit
  624. highlight-current-row
  625. stripe
  626. >
  627. <el-table-column align="center" width="55"
  628. ><template slot-scope="scope">
  629. <el-radio
  630. v-model="radioObj['radio' + cusIndex]"
  631. :label="scope.row.id"
  632. >{{ "" }}</el-radio
  633. >
  634. </template>
  635. </el-table-column>
  636. <template v-for="col in columns">
  637. <el-table-column
  638. v-if="col.num"
  639. align="center"
  640. :label="col.lable"
  641. :prop="col.prop"
  642. :min-width="col.widht"
  643. show-overflow-tooltip
  644. >
  645. <template slot-scope="scope">
  646. <el-input v-model="scope.row.qty" size="small"></el-input>
  647. </template>
  648. </el-table-column>
  649. <el-table-column
  650. v-else-if="col.jie"
  651. align="center"
  652. :label="col.lable"
  653. :prop="col.prop"
  654. :min-width="col.widht"
  655. show-overflow-tooltip
  656. >
  657. <template slot-scope="scope">
  658. {{ scope.row.qty * scope.row.price || 0 }}
  659. </template>
  660. </el-table-column>
  661. <el-table-column
  662. v-else
  663. align="center"
  664. :label="col.lable"
  665. :prop="col.prop"
  666. :min-width="col.widht"
  667. show-overflow-tooltip
  668. >
  669. </el-table-column>
  670. </template>
  671. </el-table>
  672. <!-- 分页 -->
  673. <div style="margin: 10px 0">
  674. <el-pagination
  675. @size-change="handleSizeChange"
  676. @current-change="handleCurrentChange"
  677. :current-page="currentPage"
  678. :page-sizes="[10]"
  679. :page-size="10"
  680. layout="total, sizes, prev, pager, next, jumper"
  681. :total="popDataArr[cusIndex - 1].length || 0"
  682. >
  683. </el-pagination>
  684. </div>
  685. </template>
  686. <span slot="footer" class="dialog-footer">
  687. <el-button type="primary" @click="cusIndex -= 1">上一步</el-button>
  688. <el-button
  689. type="primary"
  690. @click="handleCondition()"
  691. v-if="popArr.length != cusIndex"
  692. >下一步</el-button
  693. >
  694. <el-button
  695. type="primary"
  696. @click="hanlePopData"
  697. v-if="popArr.length == cusIndex"
  698. >完成</el-button
  699. >
  700. </span>
  701. </template>
  702. </el-dialog>
  703. </div>
  704. </template>
  705. <script>
  706. import {
  707. getDetail,
  708. addData,
  709. editData,
  710. getSalesTypeList,
  711. getGoodsList,
  712. getWalletList,
  713. getWarehouseList,
  714. policyList,
  715. checkStock,
  716. typeList,
  717. getpolicyList,
  718. getConditionList,
  719. getConditionDetail,
  720. getpolicyTypeList,
  721. } from "@/api/supply/policy";
  722. import { getDictList } from "@/api/common";
  723. import { findElem } from "@/utils/util";
  724. export default {
  725. name: "RetailForm",
  726. componentName: "RetailForm",
  727. props: ["listItem"],
  728. filters: {
  729. status1Filter(val) {
  730. if (val === "" || val === null || val === undefined) return "未检查";
  731. else if (val === 0) return "无货";
  732. else if (val > 0 && val <= 30) return val;
  733. else if (val > 30 && val <= 1000) return "有货";
  734. else if (val > 1000) return "充足";
  735. },
  736. },
  737. data() {
  738. return {
  739. tableData: [],
  740. currentPage: 1, // 当前页码
  741. pageSize: 10, // 每页数量
  742. listTotal: 0, // 列表总数
  743. cusIndex: 0,
  744. radio: "",
  745. pop: "",
  746. popArr: [],
  747. mainForm: {
  748. id: "",
  749. date: "",
  750. type: "",
  751. ztype: "",
  752. remark: "",
  753. policyCode: "",
  754. policyRemark: "",
  755. policyId: "",
  756. },
  757. mainFormRules: {
  758. date: [
  759. { required: true, message: "请选择单据日期", trigger: "change" },
  760. ],
  761. type: [{ required: true, message: "请选择品类", trigger: "change" }],
  762. },
  763. goodsList: [],
  764. warehouseList: [],
  765. warehouseValue: "",
  766. isShowDialog: false,
  767. screenForm: {
  768. policyId: "",
  769. saleTypeCode: "",
  770. },
  771. currentPage: 1,
  772. listTotal: 0,
  773. salesTypeList: [],
  774. typeList: [],
  775. ztypeList: [],
  776. leftGoodsList: [],
  777. rightGoodsList: [],
  778. leftSelection: [],
  779. rightSelection: [],
  780. policyList: [],
  781. xjWalletList: [],
  782. flWalletList: [],
  783. dataList: [],
  784. columns: [
  785. {
  786. prop: "saleTypeName",
  787. lable: "销售类型",
  788. widht: 160,
  789. },
  790. {
  791. prop: "materialName",
  792. lable: "货品名称",
  793. widht: 160,
  794. },
  795. {
  796. prop: "specification",
  797. lable: "规格型号",
  798. widht: 160,
  799. },
  800. {
  801. prop: "qty",
  802. lable: "数量",
  803. widht: 160,
  804. num: true,
  805. },
  806. {
  807. prop: "price",
  808. lable: "单价",
  809. widht: 160,
  810. },
  811. {
  812. prop: "zong",
  813. lable: "金额",
  814. jie: true,
  815. },
  816. ],
  817. listLoading: false,
  818. popDataArr: [],
  819. radioObj: {},
  820. step: 0,
  821. };
  822. },
  823. computed: {
  824. sidebar() {
  825. return this.$store.state.app.sidebar;
  826. },
  827. classObj() {
  828. return {
  829. hideSidebar: !this.sidebar.opened,
  830. openSidebar: this.sidebar.opened,
  831. };
  832. },
  833. comxjWalletList() {
  834. return (c) => {
  835. console.log(c, "现金钱包");
  836. const walle = [];
  837. const ovalVall = c == undefined || !c.length ? [] : c;
  838. for (let i = 0; i < this.xjWalletList.length; i++) {
  839. for (let j = 0; j < ovalVall.length; j++) {
  840. if (this.xjWalletList[i].walletRebateId == ovalVall[j].walletId) {
  841. walle.push(this.xjWalletList[i]);
  842. }
  843. }
  844. }
  845. return walle;
  846. };
  847. },
  848. comText() {
  849. return (val) => {
  850. const params = this.radio.split("&");
  851. if (this.cusIndex - 1 == 0) {
  852. return this.dataList.filter((k) => {
  853. console.log(k, params[0]);
  854. return k.id == params[0];
  855. })[0][val];
  856. } else {
  857. return this.popDataArr[this.cusIndex - 1].filter((k) => {
  858. return k.id == params[0];
  859. })[0][val];
  860. }
  861. };
  862. // console.log();
  863. },
  864. },
  865. created() {
  866. this.getDictList();
  867. this.getWalletList();
  868. this.getWarehouseList();
  869. this.getTypeList();
  870. if (this.listItem) {
  871. this.getDetail();
  872. }
  873. },
  874. beforeUpdate() {
  875. },
  876. methods: {
  877. // 返回列表
  878. goBack() {
  879. this.$emit("backListFormDetail");
  880. },
  881. // 获取详情
  882. getDetail() {
  883. getDetail({ id: this.listItem.id }).then((res) => {
  884. let data = res.data;
  885. this.mainForm.date = data.theTime;
  886. this.mainForm.type = data.mainId;
  887. this.mainForm.remark = data.remark;
  888. data.retailOrderItemList.forEach((item) => {
  889. item.status1 = "";
  890. item.status2 = "";
  891. });
  892. this.goodsList = data.retailOrderItemList;
  893. });
  894. },
  895. // 获取销售政策
  896. getPolicyList() {
  897. policyList({
  898. pageNum: 1,
  899. pageSize: -1,
  900. }).then((res) => {
  901. console.log(res, "tyep");
  902. this.policyList = res.data.records;
  903. this.screenForm.policyId = res.data.records[0].code;
  904. });
  905. },
  906. getTypeList() {
  907. const params = {
  908. pageNum: 1,
  909. pageSize: -1,
  910. saleCode: "",
  911. saleName: "",
  912. status: "",
  913. };
  914. typeList(params).then((res) => {
  915. this.ztypeList = res.data.records;
  916. console.log(this.ztypeList, "type1111");
  917. });
  918. },
  919. handleSelectiontAllChange(e) {
  920. console.log(e);
  921. },
  922. handleSelectionChange(e) {
  923. console.log(e);
  924. },
  925. // 获取仓库列表
  926. getWarehouseList() {
  927. getWarehouseList({
  928. pageNum: 1,
  929. pageSize: -1,
  930. }).then((res) => {
  931. this.warehouseList = res.data.records;
  932. });
  933. },
  934. // 获取限定机型
  935. getpolicyTypeList() {
  936. getpolicyTypeList({
  937. pageNum: 1,
  938. pageSize: 10,
  939. policyId: this.screenForm.policyId,
  940. saleTypeCode: this.screenForm.saleTypeCode,
  941. }).then((res) => {
  942. for (let i = 0; i < res.data.records.length; i++) {
  943. res.data.records[i].qty = 1;
  944. }
  945. this.dataList = res.data.records;
  946. console.log(this.dataList, "kkkk");
  947. });
  948. },
  949. getMaterialTypeList() {
  950. getMaterialTypeList({
  951. pageNum: 1,
  952. pageSize: 10,
  953. policyId: this.screenForm.policyId,
  954. saleTypeCode: this.screenForm.saleTypeCode,
  955. }).then((res) => {});
  956. },
  957. //引用销售政策搜索
  958. handlePolicyTypeList() {
  959. this.getpolicyTypeList();
  960. },
  961. handleShow() {
  962. this.isShowDialog = true;
  963. this.getPolicyList()
  964. },
  965. // 获取钱包列表
  966. getWalletList() {
  967. getWalletList({
  968. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  969. type: "COMMONLY",
  970. }).then((res) => {
  971. this.xjWalletList = res.data;
  972. console.log(res.data, "xxxxx");
  973. });
  974. getWalletList({
  975. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  976. type: "REBATE",
  977. }).then((res) => {
  978. this.flWalletList = res.data;
  979. console.log(this.flWalletList, "xxccc");
  980. });
  981. },
  982. // 获取销售类型列表
  983. getSalesTypeList() {
  984. getSalesTypeList({
  985. pageNum: 1,
  986. pageSize: -1,
  987. }).then((res) => {
  988. this.salesTypeList = res.data.records;
  989. });
  990. },
  991. getDictList() {
  992. getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  993. this.typeList = res.data;
  994. });
  995. },
  996. // 获取商品列表
  997. getGoodsList() {
  998. getGoodsList({
  999. pageNum: this.currentPage,
  1000. pageSize: 10,
  1001. mainId: this.screenForm.type,
  1002. saleId: this.screenForm.salesType,
  1003. materialCode: this.screenForm.proNum,
  1004. materialName: this.screenForm.proName,
  1005. specification: this.screenForm.proModel,
  1006. price1: this.screenForm.price1,
  1007. price2: this.screenForm.price2,
  1008. }).then((res) => {
  1009. let oldGoodsList = this.goodsList;
  1010. let newGoodsList = res.data.records;
  1011. for (let i = 0; i < oldGoodsList.length; i++) {
  1012. let oldItem = oldGoodsList[i];
  1013. for (let j = 0; j < newGoodsList.length; j++) {
  1014. let newItem = newGoodsList[j];
  1015. if (newItem.materialId === oldItem.materialId) {
  1016. newGoodsList[j].selected = true;
  1017. break;
  1018. }
  1019. }
  1020. }
  1021. res.data.records.forEach((item) => {
  1022. item.materialName = item.name;
  1023. item.materialCode = item.number;
  1024. item.saleTypeName = item.saleName;
  1025. item.unit = item.baseUnit;
  1026. item.price = item.batchPrice;
  1027. item.tax = item.taxRate;
  1028. item.isDirectTransfer = false;
  1029. item.directTransferQty = "";
  1030. item.status1 = "";
  1031. item.status2 = "";
  1032. item.rebateAmount = "";
  1033. item.rebateRate = "";
  1034. item.productPriceId = item.id;
  1035. });
  1036. this.leftGoodsList = res.data.records;
  1037. this.listTotal = res.data.total;
  1038. });
  1039. },
  1040. // 查询重复值并禁选
  1041. checkboxSelect(row, rowIndex) {
  1042. if (row.selected) {
  1043. return false; // 禁用
  1044. } else {
  1045. return true; // 不禁用
  1046. }
  1047. },
  1048. // 点击 选择商品
  1049. openDialog() {
  1050. this.getSalesTypeList();
  1051. this.getGoodsList();
  1052. this.isShowDialog = true;
  1053. },
  1054. // 提交筛选表单
  1055. submitScreenForm() {
  1056. this.currentPage = 1;
  1057. this.getGoodsList();
  1058. },
  1059. // 重置筛选表单
  1060. resetScreenForm() {
  1061. this.$refs.screenForm.resetFields();
  1062. this.currentPage = 1;
  1063. this.getGoodsList();
  1064. },
  1065. // 更改列表当前页
  1066. handleTableCurrentChange(val) {
  1067. this.currentPage = val;
  1068. this.getGoodsList();
  1069. },
  1070. // 关闭 弹窗
  1071. closeDialog() {
  1072. this.isShowDialog = false;
  1073. },
  1074. // 删除
  1075. deleteGoods() {
  1076. let rightGoodsList = this.rightGoodsList;
  1077. let rightSelection = this.rightSelection;
  1078. for (let i = 0; i < rightGoodsList.length; i++) {
  1079. for (let j = 0; j < rightSelection.length; j++) {
  1080. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1081. this.rightGoodsList.splice(i, 1);
  1082. }
  1083. }
  1084. }
  1085. },
  1086. handleCondition() {
  1087. if (Object.values(this.radioObj)[this.cusIndex - 1] !== "") {
  1088. this.popArr.length >= this.cusIndex ? (this.cusIndex += 1) : "";
  1089. const params = this.radio.split("&");
  1090. this.step = this.cusIndex + 1;
  1091. this.getConditionList(params[3], this.step);
  1092. return;
  1093. } else {
  1094. this.$errorMsg("请选择");
  1095. }
  1096. },
  1097. // 确定 添加产品
  1098. submitAddGoods() {
  1099. if (this.radio) {
  1100. const params = this.radio.split("&");
  1101. this.screenForm.policyId = params[1];
  1102. this.mainForm.policyId = params[1];
  1103. this.cusIndex += 1;
  1104. getpolicyList({
  1105. materialId: params[2],
  1106. policyId: params[1],
  1107. }).then((res) => {
  1108. this.pop = res.data.pop;
  1109. this.popArr = res.data.pop.split(":");
  1110. this.popArr.splice(0, 1);
  1111. console.log(this.popArr);
  1112. console.log;
  1113. for (let i = 0; i < this.popArr.length; i++) {
  1114. this.$set(this.radioObj, "radio" + (i + 1), "");
  1115. }
  1116. this.step = this.cusIndex + 1;
  1117. this.screenForm.policyId = "";
  1118. this.getConditionList(params[3], this.step);
  1119. });
  1120. } else {
  1121. this.$errorMsg("请选择");
  1122. }
  1123. },
  1124. // 更改每页数量
  1125. handleSizeChange(val) {
  1126. this.pageSize = val;
  1127. this.currentPage = 1;
  1128. const params = this.radio.split("&");
  1129. this.step = this.cusIndex + 1;
  1130. this.getConditionList(params[3], this.step);
  1131. },
  1132. // 更改当前页
  1133. handleCurrentChange(val) {
  1134. this.currentPage = val;
  1135. const params = this.radio.split("&");
  1136. this.step = this.cusIndex + 1;
  1137. this.getConditionList(params[3], this.step);
  1138. },
  1139. getConditionList(policyConditionId, popType) {
  1140. let arr = []
  1141. getConditionList({
  1142. pageNum: this.currentPage,
  1143. pageSize: this.pageSize,
  1144. policyConditionId,
  1145. popType,
  1146. }).then((res) => {
  1147. console.log(this.cusIndex);
  1148. const datas = res.data.records
  1149. for (let i = 0; i < res.data.records.length; i++) {
  1150. res.data.records[i].qty = 1;
  1151. }
  1152. if (this.popDataArr.length) {
  1153. this.popDataArr.splice(this.cusIndex - 1, 1);
  1154. }
  1155. if (this.cusIndex == 0) {
  1156. this.popDataArr = [];
  1157. }
  1158. if (this.cusIndex == 1) {
  1159. for (let l = 0; l < this.dataList.length; l++) {
  1160. for (let k = 0; k < datas.length; k++) {
  1161. console.log(this.dataList[l].id == datas[k].id,'hahah',datas,this.dataList);
  1162. if (this.dataList[l].id == datas[k].id) {
  1163. datas.splice(k,1)
  1164. }
  1165. }
  1166. }
  1167. this.popDataArr.push(datas);
  1168. }else{
  1169. for (let j = 0; j < this.popDataArr[this.cusIndex-1].length; j++) {
  1170. for (let k = 0; k < datas.length; k++) {
  1171. if (this.dataList[l].id == datas[k].id) {
  1172. datas.splice(k,1)
  1173. }
  1174. }
  1175. }
  1176. this.popDataArr.push(datas);
  1177. }
  1178. // this.popDataArr.push(res.data.records);
  1179. });
  1180. },
  1181. hanlePopData() {
  1182. if (!Object.values(this.radioObj).includes("")) {
  1183. let arrData = [];
  1184. for (let i = 0; i < this.popDataArr.length; i++) {
  1185. arrData = [...arrData, ...this.popDataArr[i]];
  1186. }
  1187. for (let j = 0; j < arrData.length; j++) {
  1188. for (const key in this.radioObj) {
  1189. if (arrData[j].id == this.radioObj[key]) {
  1190. console.log(arrData[j], "xxxx");
  1191. this.goodsList = [...this.goodsList, arrData[j]];
  1192. }
  1193. }
  1194. }
  1195. const params = this.radio.split("&");
  1196. let arr = [];
  1197. console.log(this.dataList, "dataList");
  1198. for (let k = 0; k < this.dataList.length; k++) {
  1199. if (this.dataList[k].id == params[0]) {
  1200. arr = [this.dataList[k]];
  1201. console.log(...arr, "jjjjj");
  1202. }
  1203. }
  1204. this.goodsList = [...arr, ...this.goodsList];
  1205. this.goodsList.forEach((item) => {
  1206. this.$set(item, "status1", "");
  1207. this.$set(item, "status2", "");
  1208. });
  1209. this.cusIndex = 0;
  1210. this.radio = "";
  1211. this.dataList = [];
  1212. this.screenForm.policyId = "";
  1213. this.screenForm.saleTypeCode = "";
  1214. this.isShowDialog = false;
  1215. } else {
  1216. this.$errorMsg("请选择");
  1217. }
  1218. },
  1219. handleClose() {
  1220. this.cusIndex = 0;
  1221. this.radio = "";
  1222. this.dataList = [];
  1223. this.screenForm.policyId = "";
  1224. this.screenForm.saleTypeCode = "";
  1225. },
  1226. // 删除产品
  1227. deleteItem(index) {
  1228. this.goodsList.splice(index, 1);
  1229. },
  1230. // 修改返利钱包
  1231. changeWallet(index) {
  1232. if (this.goodsList[index].customerWalletId2) {
  1233. let obj = this.flWalletList.find(
  1234. (o) => o.customerWalletId == this.goodsList[index].customerWalletId2
  1235. );
  1236. this.goodsList[index].rebateRate = obj.rebateRate;
  1237. } else {
  1238. this.goodsList[index].rebateRate = "";
  1239. }
  1240. },
  1241. // 检查库存
  1242. checkStock() {
  1243. if (!this.warehouseValue) {
  1244. return this.$errorMsg("请选择仓库");
  1245. }
  1246. if (!this.goodsList) {
  1247. return this.$errorMsg("请添加货品");
  1248. }
  1249. let ids = [];
  1250. this.goodsList.forEach((item) => {
  1251. ids.push(item.materialId);
  1252. });
  1253. checkStock({
  1254. correspondId: this.warehouseValue,
  1255. materialId: ids.join(","),
  1256. }).then((res) => {
  1257. if (res.data) {
  1258. this.goodsList.forEach((item, index) => {
  1259. item.status1 = res.data[index].allStockNum;
  1260. item.status2 = res.data[index].stockNum;
  1261. console.log(item.status1, item.status2);
  1262. });
  1263. }
  1264. });
  1265. },
  1266. status2Filter(item) {
  1267. if (
  1268. item.status2 === "" ||
  1269. item.status2 === null ||
  1270. item.status2 === undefined
  1271. )
  1272. return "未检查";
  1273. else if (item.status2 >= item.qty) return "可用";
  1274. else return "短缺";
  1275. },
  1276. // 保存
  1277. clickSubmitForm() {
  1278. this.$refs.mainForm.validate((valid) => {
  1279. if (valid) {
  1280. let mainName =
  1281. this.typeList[
  1282. findElem(this.typeList, "dictCode", this.mainForm.type)
  1283. ].dictValue;
  1284. let params = {
  1285. theTime: this.mainForm.date + " 00:00:00",
  1286. mainId: this.mainForm.type,
  1287. mainName,
  1288. remark: this.mainForm.remark,
  1289. type: 2, // 1:普通零售单,2:政策零售单
  1290. retailOrderItemList: this.goodsList,
  1291. policyId: this.screenForm.policyId,
  1292. };
  1293. if (this.listItem) {
  1294. params.id = this.listItem.id;
  1295. editData(params).then((res) => {
  1296. this.$successMsg("编辑成功");
  1297. this.goBack();
  1298. this.$parent.getList();
  1299. });
  1300. } else {
  1301. addData(params).then((res) => {
  1302. this.$successMsg("添加成功");
  1303. this.goBack();
  1304. this.$parent.getList();
  1305. });
  1306. }
  1307. }
  1308. });
  1309. },
  1310. },
  1311. };
  1312. </script>
  1313. <style scoped lang="scss">
  1314. .fr {
  1315. margin: 10px;
  1316. overflow: hidden;
  1317. }
  1318. .detail-container {
  1319. width: 100%;
  1320. height: 100%;
  1321. }
  1322. .main-title {
  1323. display: flex;
  1324. justify-content: space-between;
  1325. align-items: center;
  1326. margin-top: 20px;
  1327. height: 60px;
  1328. border-bottom: 1px solid #dcdfe6;
  1329. margin-bottom: 20px;
  1330. .title {
  1331. font-size: 16px;
  1332. font-weight: 600;
  1333. padding-left: 10px;
  1334. }
  1335. }
  1336. .tables {
  1337. display: flex;
  1338. margin-top: 10px;
  1339. .table {
  1340. width: 45%;
  1341. }
  1342. .buttons {
  1343. display: flex;
  1344. flex-direction: column;
  1345. justify-content: center;
  1346. align-items: center;
  1347. padding: 0 10px;
  1348. button {
  1349. margin: 0;
  1350. margin-top: 10px;
  1351. }
  1352. }
  1353. }
  1354. </style>