retail_form.vue 46 KB

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