retail_form.vue 59 KB

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