retail_form.vue 46 KB

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