retail_form.vue 55 KB

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