retail_form.vue 58 KB

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