retail_form2.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. label-width="120px"
  14. size="small"
  15. label-position="right"
  16. >
  17. <el-row :gutter="20">
  18. <el-col
  19. :xs="24"
  20. :sm="12"
  21. :lg="8"
  22. v-if="!listItem"
  23. @click.native="handleShow"
  24. >
  25. <el-form-item label="销售政策编号" prop="policyCode">
  26. <el-input
  27. v-model="policyId"
  28. placeholder="销售政策编号"
  29. readonly
  30. ></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="8" v-else>
  34. <el-form-item label="销售政策编号" prop="policyCode">
  35. <el-input
  36. v-model="mainForm.policyCode"
  37. placeholder="销售政策编号"
  38. ></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  42. <el-form-item label="单据日期" prop="date">
  43. <el-date-picker
  44. v-model="mainForm.date"
  45. type="datetime"
  46. disabled
  47. style="width: 100%"
  48. placeholder="选择日期"
  49. >
  50. </el-date-picker>
  51. </el-form-item>
  52. </el-col>
  53. <!-- <el-col :xs="24" :sm="12" :lg="8">
  54. <el-form-item label="产品大类" prop="type">
  55. <el-select
  56. v-model="mainForm.type"
  57. placeholder="选择产品大类"
  58. style="width: 100%"
  59. >
  60. <el-option
  61. v-for="item in typeList"
  62. :key="item.dictCode"
  63. :label="item.dictValue"
  64. :value="item.dictCode"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col> -->
  69. <el-col :xs="24" :sm="8" :lg="8">
  70. <el-form-item label="备注" prop="remark">
  71. <el-input
  72. v-model="mainForm.remark"
  73. placeholder="请输入备注"
  74. ></el-input>
  75. </el-form-item>
  76. </el-col>
  77. </el-row>
  78. </el-form>
  79. <div class="main-title">
  80. <div class="title">货品信息</div>
  81. <div v-if="!listItem">
  82. <el-select
  83. v-model="warehouseValue"
  84. placeholder="请选择发货仓库"
  85. size="small"
  86. style="margin-right: 10px"
  87. >
  88. <el-option
  89. :label="item.name"
  90. :value="item.id"
  91. v-for="(item, index) in warehouseList"
  92. :key="index"
  93. ></el-option>
  94. </el-select>
  95. <el-button
  96. type="primary"
  97. size="small"
  98. icon="el-icon-search"
  99. @click="checkStock"
  100. >检查库存</el-button
  101. >
  102. <el-divider direction="vertical"></el-divider>
  103. </div>
  104. </div>
  105. <div class="table" style="margin-top: 20px">
  106. <el-table
  107. :data="goodsList"
  108. element-loading-text="Loading"
  109. border
  110. fit
  111. highlight-current-row
  112. stripe
  113. max-height="400"
  114. >
  115. <el-table-column
  116. align="center"
  117. label="序号"
  118. type="index"
  119. width="50"
  120. ></el-table-column>
  121. <el-table-column
  122. align="center"
  123. label="销售类型"
  124. prop="saleTypeName"
  125. min-width="100"
  126. show-overflow-tooltip
  127. ></el-table-column>
  128. <el-table-column
  129. align="center"
  130. label="存货编码"
  131. prop="materialNumber"
  132. min-width="100"
  133. show-overflow-tooltip
  134. ></el-table-column>
  135. <el-table-column
  136. align="center"
  137. label="产品名称"
  138. prop="materialName"
  139. min-width="160"
  140. show-overflow-tooltip
  141. ></el-table-column>
  142. <el-table-column
  143. align="center"
  144. label="规格型号"
  145. prop="specification"
  146. min-width="160"
  147. show-overflow-tooltip
  148. ></el-table-column>
  149. <el-table-column
  150. align="center"
  151. label="单位"
  152. prop="unit"
  153. min-width="100"
  154. show-overflow-tooltip
  155. ></el-table-column>
  156. <el-table-column
  157. align="center"
  158. label="单价"
  159. prop="price"
  160. min-width="100"
  161. show-overflow-tooltip
  162. ></el-table-column>
  163. <el-table-column
  164. align="center"
  165. label="总数量"
  166. prop="qty"
  167. min-width="100"
  168. show-overflow-tooltip
  169. >
  170. <template slot-scope="scope">
  171. <el-input v-model="scope.row.qty" size="small"></el-input>
  172. </template>
  173. </el-table-column>
  174. <el-table-column
  175. align="center"
  176. label="订单金额"
  177. min-width="100"
  178. show-overflow-tooltip
  179. >
  180. <template slot-scope="scope">
  181. {{ scope.row.price * scope.row.qty }}
  182. </template>
  183. </el-table-column>
  184. <el-table-column
  185. align="center"
  186. label="返利钱包"
  187. prop="customerWalletId2"
  188. min-width="160"
  189. show-overflow-tooltip
  190. >
  191. <template slot-scope="scope">
  192. <el-select
  193. v-model="scope.row.customerWalletId2"
  194. placeholder="选择返利钱包"
  195. size="small"
  196. @change="changeWallet(scope.$index)"
  197. >
  198. <el-option
  199. v-for="item in scope.row.rebateWallets"
  200. :key="item.customerWalletId"
  201. :label="item.name"
  202. :value="item.customerWalletId"
  203. >
  204. </el-option>
  205. </el-select>
  206. </template>
  207. </el-table-column>
  208. <el-table-column
  209. align="center"
  210. label="返利金额"
  211. min-width="100"
  212. show-overflow-tooltip
  213. >
  214. <template slot-scope="scope">
  215. {{
  216. (scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) /
  217. 100 || 0
  218. }}
  219. </template>
  220. </el-table-column>
  221. <el-table-column
  222. align="center"
  223. label="格力折扣"
  224. min-width="100"
  225. show-overflow-tooltip
  226. >
  227. <template slot-scope="scope">
  228. {{ scope.row.qty * scope.row.discAmount }}
  229. </template>
  230. </el-table-column>
  231. <el-table-column
  232. align="center"
  233. label="已退数量"
  234. prop="retiredQty"
  235. min-width="100"
  236. show-overflow-tooltip
  237. ></el-table-column>
  238. <el-table-column
  239. align="center"
  240. label="现金钱包"
  241. prop="customerWalletId"
  242. min-width="160"
  243. show-overflow-tooltip
  244. >
  245. <template slot-scope="scope">
  246. <el-select
  247. v-model="scope.row.customerWalletId"
  248. placeholder="选择现金钱包"
  249. size="small"
  250. >
  251. <el-option
  252. v-for="item in scope.row.wallets"
  253. :key="item.customerWalletId"
  254. :label="item.name"
  255. :value="item.customerWalletId"
  256. >
  257. </el-option>
  258. </el-select>
  259. </template>
  260. </el-table-column>
  261. <el-table-column
  262. align="center"
  263. label="实付金额"
  264. prop="qty"
  265. min-width="100"
  266. show-overflow-tooltip
  267. >
  268. <template slot-scope="scope">
  269. {{
  270. (scope.row.price * scope.row.qty * 100 -
  271. ((scope.row.price *
  272. scope.row.qty *
  273. (scope.row.rebateRate * 100)) /
  274. 100) *
  275. 100 -
  276. ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) /
  277. 100 || 0
  278. }}
  279. </template>
  280. </el-table-column>
  281. <el-table-column
  282. align="center"
  283. label="是否直调"
  284. prop="isDirectTransfer"
  285. min-width="100"
  286. >
  287. <template slot-scope="scope">
  288. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  289. </template>
  290. </el-table-column>
  291. <!-- <el-table-column
  292. align="center"
  293. label="直调数量"
  294. prop="directTransferQty"
  295. min-width="100"
  296. >
  297. <template slot-scope="scope">
  298. <el-input
  299. v-model="scope.row.directTransferQty"
  300. size="small"
  301. ></el-input>
  302. </template>
  303. </el-table-column> -->
  304. <el-table-column
  305. align="center"
  306. label="备注"
  307. prop="remark"
  308. min-width="160"
  309. >
  310. <template slot-scope="scope">
  311. <el-input v-model="scope.row.remark" size="small"></el-input>
  312. </template>
  313. </el-table-column>
  314. <el-table-column
  315. align="center"
  316. label="税率"
  317. prop="tax"
  318. min-width="100"
  319. show-overflow-tooltip
  320. ></el-table-column>
  321. <el-table-column
  322. align="center"
  323. label="总仓库"
  324. prop="status1"
  325. min-width="100"
  326. show-overflow-tooltip
  327. v-if="!listItem"
  328. >
  329. <template slot-scope="scope">
  330. <div>{{ scope.row.status1 | status1Filter }}</div>
  331. </template>
  332. </el-table-column>
  333. <el-table-column
  334. align="center"
  335. label="仓库状态"
  336. prop="status2"
  337. min-width="100"
  338. show-overflow-tooltip
  339. v-if="!listItem"
  340. >
  341. <template slot-scope="scope">
  342. <div>{{ status2Filter(scope.row) }}</div>
  343. </template>
  344. </el-table-column>
  345. <el-table-column align="center" label="操作" width="100" fixed="right">
  346. <template slot-scope="scope">
  347. <!-- <el-button
  348. type="text"
  349. @click="(dialogVisible = true), (cid = scope.row.id)"
  350. >修改</el-button
  351. > -->
  352. <el-button type="text" @click="deleteItem(scope.$index)"
  353. >删除</el-button
  354. >
  355. </template>
  356. </el-table-column>
  357. </el-table>
  358. </div>
  359. <el-dialog :visible.sync="dialogVisible" width="50%">
  360. <el-form label-width="80px" :inline="false" size="small">
  361. <el-form-item label="单据日期" prop="date">
  362. <el-date-picker
  363. v-model="mainForm.date"
  364. type="datetime"
  365. value-format="yyyy-MM-dd HH:mm:ss"
  366. style="width: 100%"
  367. placeholder="选择日期"
  368. >
  369. </el-date-picker>
  370. </el-form-item>
  371. </el-form>
  372. <span slot="footer" class="dialog-footer">
  373. <el-button @click="dialogVisible = false">取 消</el-button>
  374. <el-button type="primary" size="small" @click="hendleEdit"
  375. >确 定</el-button
  376. >
  377. </span>
  378. </el-dialog>
  379. <div class="page-footer">
  380. <div class="footer" :class="classObj">
  381. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  382. <el-popconfirm
  383. title="确定关闭吗?"
  384. @onConfirm="goBack"
  385. style="margin-left: 10px"
  386. >
  387. <el-button slot="reference">关 闭</el-button>
  388. </el-popconfirm>
  389. </div>
  390. </div>
  391. <el-dialog
  392. :visible.sync="isShowDialog"
  393. @close="handleClose"
  394. width="80%"
  395. :close-on-click-modal="false"
  396. title="引用销售政策"
  397. >
  398. <template>
  399. <el-form
  400. :model="screenForm"
  401. ref="screenForm"
  402. label-width="120px"
  403. size="small"
  404. >
  405. <el-row :gutter="20">
  406. <el-col :xs="24" :sm="6" :lg="6">
  407. <el-form-item label="销售政策">
  408. <el-select
  409. v-model="screenForm.policyId"
  410. placeholder="选择销售政策"
  411. @change="handlePolicy"
  412. filterable
  413. :disabled="disabled"
  414. style="width: 100%"
  415. >
  416. <el-option
  417. v-for="(item, index) in policyList"
  418. :key="index"
  419. :label="item.title"
  420. :value="item.code"
  421. ></el-option>
  422. </el-select> </el-form-item
  423. ></el-col>
  424. <el-col :xs="24" :sm="6" :lg="6">
  425. <el-form-item label="条件">
  426. <el-select
  427. v-model="screenForm.factorId"
  428. filterable
  429. @change="handleFactor"
  430. placeholder="选择条件"
  431. style="width: 100%"
  432. >
  433. <el-option
  434. v-for="(item, index) in factor"
  435. :key="item.id"
  436. :label="'条件' + (index + 1)"
  437. :value="item.id"
  438. ></el-option>
  439. </el-select>
  440. </el-form-item>
  441. </el-col>
  442. <el-col :xs="24" :sm="6" :lg="6">
  443. <el-form-item label="销售类型">
  444. <el-select
  445. v-model="screenForm.saleTypeCode"
  446. filterable
  447. placeholder="选择销售类型"
  448. style="width: 100%"
  449. >
  450. <el-option
  451. v-for="item in ztypeList"
  452. :key="item.id"
  453. :label="item.saleName"
  454. :value="item.saleCode"
  455. ></el-option>
  456. </el-select>
  457. </el-form-item>
  458. </el-col>
  459. <el-col :xs="24" :sm="6" :lg="6" class="tr">
  460. <el-button
  461. type="primary"
  462. size="small"
  463. @click="handlePolicyTypeList"
  464. >查询</el-button
  465. >
  466. </el-col>
  467. </el-row>
  468. </el-form>
  469. <template v-if="!dataList.length">
  470. <el-row :gutter="20" style="margin: 10px 0">
  471. {{ cusIndex > 0 ? "选择配提机型" : "选择限定机型" }}
  472. {{ "(" + pop + ")" }}
  473. </el-row>
  474. <el-table
  475. v-loading="listLoading"
  476. :data="popDataArr[cusIndex]"
  477. element-loading-text="Loading"
  478. border
  479. fit
  480. highlight-current-row
  481. @select-all="handleSelectionChange"
  482. @selection-change="handleSelectionChange"
  483. stripe
  484. >
  485. <el-table-column
  486. align="center"
  487. type="selection"
  488. :selectable="selectable"
  489. width="55"
  490. >
  491. </el-table-column>
  492. <template v-for="col in columns">
  493. <el-table-column
  494. v-if="col.num"
  495. align="center"
  496. :label="col.lable"
  497. :prop="col.prop"
  498. :min-width="col.widht"
  499. show-overflow-tooltip
  500. >
  501. <template slot-scope="scope">
  502. <el-input v-model="scope.row.qty" size="small"></el-input>
  503. </template>
  504. </el-table-column>
  505. <el-table-column
  506. v-else-if="col.jie"
  507. align="center"
  508. :label="col.lable"
  509. :prop="col.prop"
  510. :min-width="col.widht"
  511. show-overflow-tooltip
  512. >
  513. <template slot-scope="scope">
  514. {{ scope.row.qty * scope.row.price || 0 }}
  515. </template>
  516. </el-table-column>
  517. <el-table-column
  518. v-else
  519. align="center"
  520. :label="col.lable"
  521. :prop="col.prop"
  522. :min-width="col.widht"
  523. show-overflow-tooltip
  524. >
  525. </el-table-column>
  526. </template>
  527. </el-table>
  528. <div style="margin: 10px 0">
  529. <el-pagination
  530. @size-change="handleSizeChange"
  531. @current-change="handleCurrentChange"
  532. :current-page="currentPage"
  533. :page-sizes="[10]"
  534. :page-size="10"
  535. layout="total, sizes, prev, pager, next, jumper"
  536. :total="total"
  537. >
  538. </el-pagination>
  539. </div>
  540. <span slot="footer" class="dialog-footer">
  541. <el-button type="primary" v-if="cusIndex > 0" @click="handleShang"
  542. >上一步</el-button
  543. >
  544. <el-button
  545. type="primary"
  546. @click="handleCondition"
  547. v-if="popArr.length != cusIndex + 1"
  548. >下一步</el-button
  549. >
  550. <el-button
  551. type="primary"
  552. @click="hanlePopData"
  553. v-if="popArr.length == cusIndex + 1"
  554. >完成</el-button
  555. >
  556. </span>
  557. </template>
  558. <template v-else>
  559. <el-table
  560. v-loading="listLoading"
  561. :data="dataList"
  562. element-loading-text="Loading"
  563. border
  564. fit
  565. highlight-current-row
  566. @select-all="handleSelectionChange"
  567. @selection-change="handleSelectionChange"
  568. stripe
  569. >
  570. <el-table-column
  571. align="center"
  572. type="selection"
  573. :selectable="selectable"
  574. width="55"
  575. >
  576. </el-table-column>
  577. <template v-for="col in columns">
  578. <el-table-column
  579. v-if="col.num"
  580. align="center"
  581. :label="col.lable"
  582. :prop="col.prop"
  583. :min-width="col.widht"
  584. show-overflow-tooltip
  585. >
  586. <template slot-scope="scope">
  587. <el-input v-model="scope.row.qty" size="small"></el-input>
  588. </template>
  589. </el-table-column>
  590. <el-table-column
  591. v-else-if="col.jie"
  592. align="center"
  593. :label="col.lable"
  594. :prop="col.prop"
  595. :min-width="col.widht"
  596. show-overflow-tooltip
  597. >
  598. <template slot-scope="scope">
  599. {{ scope.row.qty * scope.row.price || 0 }}
  600. </template>
  601. </el-table-column>
  602. <el-table-column
  603. v-else
  604. align="center"
  605. :label="col.lable"
  606. :prop="col.prop"
  607. :min-width="col.widht"
  608. show-overflow-tooltip
  609. >
  610. </el-table-column>
  611. </template>
  612. </el-table>
  613. <div style="margin: 10px 0">
  614. <el-pagination
  615. @size-change="handleSizeChange"
  616. @current-change="handleCurrentChange"
  617. :current-page="currentPage"
  618. :page-sizes="[10]"
  619. :page-size="10"
  620. layout="total, sizes, prev, pager, next, jumper"
  621. :total="total"
  622. >
  623. </el-pagination>
  624. </div>
  625. <span slot="footer" class="dialog-footer">
  626. <el-button
  627. type="primary"
  628. @click="hanlePopData"
  629. >完成</el-button
  630. >
  631. </span>
  632. </template>
  633. </template>
  634. </el-dialog>
  635. </div>
  636. </template>
  637. <script>
  638. import {
  639. getDetail,
  640. addData,
  641. editData,
  642. getSalesTypeList,
  643. getGoodsList,
  644. getWalletList,
  645. getWarehouseList,
  646. policyList,
  647. checkStock,
  648. typeList,
  649. getpolicyList,
  650. getConditionList,
  651. getConditionDetail,
  652. getpolicyTypeList,
  653. getMaterialTypeList ,
  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.getMaterialTypeList();
  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. for (let i = 0; i < res.data.records.length; i++) {
  1048. res.data.records[i].qty = 1;
  1049. }
  1050. this.dataList = res.data.records;
  1051. this.total = res.data.total;
  1052. console.log(this.dataList, "kkkk");
  1053. });
  1054. },
  1055. handleShow() {
  1056. this.isShowDialog = true;
  1057. this.getPolicyList();
  1058. },
  1059. // 获取钱包列表
  1060. getWalletList() {
  1061. getWalletList({
  1062. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  1063. type: "COMMONLY",
  1064. }).then((res) => {
  1065. this.xjWalletList = res.data;
  1066. });
  1067. getWalletList({
  1068. customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
  1069. type: "REBATE",
  1070. }).then((res) => {
  1071. this.flWalletList = res.data;
  1072. });
  1073. },
  1074. // 获取销售类型列表
  1075. getSalesTypeList() {
  1076. getSalesTypeList({
  1077. pageNum: 1,
  1078. pageSize: -1,
  1079. }).then((res) => {
  1080. this.salesTypeList = res.data.records;
  1081. });
  1082. },
  1083. getDictList() {
  1084. getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
  1085. this.typeList = res.data;
  1086. });
  1087. },
  1088. // 获取商品列表
  1089. getGoodsList() {
  1090. getGoodsList({
  1091. pageNum: this.currentPage,
  1092. pageSize: 10,
  1093. mainId: this.screenForm.type,
  1094. saleId: this.screenForm.salesType,
  1095. materialCode: this.screenForm.proNum,
  1096. materialName: this.screenForm.proName,
  1097. specification: this.screenForm.proModel,
  1098. price1: this.screenForm.price1,
  1099. price2: this.screenForm.price2,
  1100. }).then((res) => {
  1101. let oldGoodsList = this.goodsList;
  1102. let newGoodsList = res.data.records;
  1103. for (let i = 0; i < oldGoodsList.length; i++) {
  1104. let oldItem = oldGoodsList[i];
  1105. for (let j = 0; j < newGoodsList.length; j++) {
  1106. let newItem = newGoodsList[j];
  1107. if (newItem.materialId === oldItem.materialId) {
  1108. newGoodsList[j].selected = true;
  1109. break;
  1110. }
  1111. }
  1112. }
  1113. res.data.records.forEach((item) => {
  1114. item.materialName = item.name;
  1115. item.materialCode = item.number;
  1116. item.saleTypeName = item.saleName;
  1117. item.unit = item.baseUnit;
  1118. item.price = item.batchPrice;
  1119. item.tax = item.taxRate;
  1120. item.isDirectTransfer = false;
  1121. item.directTransferQty = "";
  1122. item.status1 = "";
  1123. item.status2 = "";
  1124. item.rebateAmount = "";
  1125. item.rebateRate = "";
  1126. item.productPriceId = item.id;
  1127. });
  1128. this.leftGoodsList = res.data.records;
  1129. this.listTotal = res.data.total;
  1130. });
  1131. },
  1132. // 查询重复值并禁选
  1133. checkboxSelect(row, rowIndex) {
  1134. if (row.selected) {
  1135. return false; // 禁用
  1136. } else {
  1137. return true; // 不禁用
  1138. }
  1139. },
  1140. // 点击 选择商品
  1141. openDialog() {
  1142. this.getSalesTypeList();
  1143. this.getGoodsList();
  1144. this.isShowDialog = true;
  1145. },
  1146. // 提交筛选表单
  1147. submitScreenForm() {
  1148. this.currentPage = 1;
  1149. this.getGoodsList();
  1150. },
  1151. // 重置筛选表单
  1152. resetScreenForm() {
  1153. this.$refs.screenForm.resetFields();
  1154. this.currentPage = 1;
  1155. this.getGoodsList();
  1156. },
  1157. // 关闭 弹窗
  1158. closeDialog() {
  1159. this.isShowDialog = false;
  1160. },
  1161. // 删除
  1162. deleteGoods() {
  1163. let rightGoodsList = this.rightGoodsList;
  1164. let rightSelection = this.rightSelection;
  1165. for (let i = 0; i < rightGoodsList.length; i++) {
  1166. for (let j = 0; j < rightSelection.length; j++) {
  1167. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1168. this.rightGoodsList.splice(i, 1);
  1169. }
  1170. }
  1171. }
  1172. },
  1173. // 确定 添加产品
  1174. submitAddGoods() {
  1175. if (this.radio) {
  1176. const params = this.radio.split("&");
  1177. this.screenForm.policyId = params[1];
  1178. this.mainForm.policyId = params[1];
  1179. this.cusIndex += 1;
  1180. getpolicyList({
  1181. materialId: params[2],
  1182. policyId: params[1],
  1183. }).then((res) => {
  1184. this.pop = res.data.pop;
  1185. this.popArr = res.data.pop.split(":");
  1186. this.popArr.splice(0, 1);
  1187. for (let i = 0; i < this.popArr.length; i++) {
  1188. this.$set(this.radioObj, "radio" + (i + 1), "");
  1189. }
  1190. this.step = this.cusIndex + 1;
  1191. this.getConditionList(params[3], this.step);
  1192. });
  1193. } else {
  1194. this.$errorMsg("请选择");
  1195. }
  1196. },
  1197. // 更改每页数量
  1198. handleSizeChange(val) {
  1199. this.pageSize = val;
  1200. this.currentPage = 1;
  1201. this.getConditionList(this.policyConditionId, this.cusIndex + 1);
  1202. },
  1203. // 更改当前页
  1204. handleCurrentChange(val) {
  1205. this.currentPage = val;
  1206. this.getConditionList(this.policyConditionId, this.cusIndex + 1);
  1207. },
  1208. // 更改列表当前页
  1209. handleTableCurrentChange(val) {
  1210. this.currentPage = val;
  1211. this.getConditionList(this.policyConditionId, this.cusIndex + 1);
  1212. },
  1213. handleClose() {
  1214. this.cusIndex = 0;
  1215. this.radio = "";
  1216. this.dataList = [];
  1217. this.popDataArr = [];
  1218. this.screenForm.policyId = "";
  1219. this.screenForm.saleTypeCode = "";
  1220. },
  1221. // 删除产品
  1222. deleteItem(index) {
  1223. this.goodsList.splice(index, 1);
  1224. console.log(this.multipleData);
  1225. // this.popDataArr.splice(index,1)
  1226. },
  1227. // 修改返利钱包
  1228. changeWallet(index) {
  1229. if (this.goodsList[index].customerWalletId2) {
  1230. let obj = this.flWalletList.find(
  1231. (o) => o.customerWalletId == this.goodsList[index].customerWalletId2
  1232. );
  1233. this.goodsList[index].rebateRate = obj.rebateRate;
  1234. } else {
  1235. this.goodsList[index].rebateRate = "";
  1236. }
  1237. },
  1238. // 检查库存
  1239. checkStock() {
  1240. if (!this.warehouseValue) {
  1241. return this.$errorMsg("请选择仓库");
  1242. }
  1243. if (!this.goodsList) {
  1244. return this.$errorMsg("请添加货品");
  1245. }
  1246. let ids = [];
  1247. this.goodsList.forEach((item) => {
  1248. ids.push(item.materialId);
  1249. });
  1250. checkStock({
  1251. correspondId: this.warehouseValue,
  1252. materialId: ids.join(","),
  1253. }).then((res) => {
  1254. if (res.data) {
  1255. this.goodsList.forEach((item, index) => {
  1256. item.status1 = res.data[index].allStockNum;
  1257. item.status2 = res.data[index].stockNum;
  1258. console.log(item.status1, item.status2);
  1259. });
  1260. }
  1261. });
  1262. },
  1263. status2Filter(item) {
  1264. if (
  1265. item.status2 === "" ||
  1266. item.status2 === null ||
  1267. item.status2 === undefined
  1268. )
  1269. return "未检查";
  1270. else if (item.status2 >= item.qty) return "可用";
  1271. else return "短缺";
  1272. },
  1273. // 保存
  1274. clickSubmitForm() {
  1275. this.$refs.mainForm.validate((valid) => {
  1276. if (valid) {
  1277. // let mainName =
  1278. // this.typeList[
  1279. // findElem(this.typeList, "dictCode", this.mainForm.type)
  1280. // ].dictValue;
  1281. let params = {
  1282. theTime: this.mainForm.date,
  1283. mainId: this.mainForm.type,
  1284. mainName:'',
  1285. remark: this.mainForm.remark,
  1286. type: 2, // 1:普通零售单,2:政策零售单
  1287. retailOrderItemList: this.goodsList,
  1288. policyId: this.policyId,
  1289. };
  1290. if (this.listItem) {
  1291. params.id = this.listItem.id;
  1292. editData(params).then((res) => {
  1293. this.$successMsg("编辑成功");
  1294. this.goBack();
  1295. this.$parent.getList();
  1296. });
  1297. } else {
  1298. addData(params).then((res) => {
  1299. this.$successMsg("添加成功");
  1300. this.goBack();
  1301. this.$parent.getList();
  1302. });
  1303. }
  1304. }
  1305. });
  1306. },
  1307. },
  1308. };
  1309. </script>
  1310. <style scoped lang="scss">
  1311. .fr {
  1312. margin: 10px;
  1313. overflow: hidden;
  1314. }
  1315. .detail-container {
  1316. width: 100%;
  1317. height: 100%;
  1318. }
  1319. .main-title {
  1320. display: flex;
  1321. justify-content: space-between;
  1322. align-items: center;
  1323. margin-top: 20px;
  1324. height: 60px;
  1325. border-bottom: 1px solid #dcdfe6;
  1326. margin-bottom: 20px;
  1327. .title {
  1328. font-size: 16px;
  1329. font-weight: 600;
  1330. padding-left: 10px;
  1331. }
  1332. }
  1333. .tables {
  1334. display: flex;
  1335. margin-top: 10px;
  1336. .table {
  1337. width: 45%;
  1338. }
  1339. .buttons {
  1340. display: flex;
  1341. flex-direction: column;
  1342. justify-content: center;
  1343. align-items: center;
  1344. padding: 0 10px;
  1345. button {
  1346. margin: 0;
  1347. margin-top: 10px;
  1348. }
  1349. }
  1350. }
  1351. .ellipsis {
  1352. overflow: hidden;
  1353. text-overflow: ellipsis;
  1354. white-space: nowrap;
  1355. }
  1356. </style>