retail_form2.vue 40 KB

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