retail_form.vue 58 KB

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