retail_form.vue 60 KB

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