retail_form.vue 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header
  4. :content="listItem ? '编辑' : '新增'"
  5. @back="goBack"
  6. />
  7. <div class="main-title">
  8. <div class="title">订单信息</div>
  9. </div>
  10. <el-form
  11. ref="mainForm"
  12. :model="mainForm"
  13. label-width="120px"
  14. size="small"
  15. label-position="right"
  16. >
  17. <el-row :gutter="20">
  18. <el-col :xs="24" :sm="12" :lg="12">
  19. <el-form-item label="销售政策编号" prop="policyCode">
  20. <div style="display: flex">
  21. <el-input
  22. v-model="policyId"
  23. placeholder="销售政策编号"
  24. disabled
  25. />
  26. <el-button
  27. style="margin-left: 10px"
  28. size="small"
  29. @click="handleShow"
  30. >引用</el-button>
  31. </div>
  32. </el-form-item>
  33. </el-col>
  34. <!-- <el-col :xs="24" :sm="12" :lg="8" v-else>
  35. <el-form-item label="销售政策编号" prop="policyCode">
  36. <el-input
  37. disabled
  38. v-model="mainForm.policyId"
  39. placeholder="销售政策编号"
  40. ></el-input>
  41. </el-form-item>
  42. </el-col> -->
  43. <el-col :xs="24" :sm="12" :lg="12" style="height: 51px">
  44. <el-form-item label="单据日期" prop="date">
  45. <el-date-picker
  46. v-model="mainForm.date"
  47. type="datetime"
  48. disabled
  49. style="width: 100%"
  50. placeholder="选择日期"
  51. />
  52. </el-form-item>
  53. </el-col>
  54. <el-col :xs="24" :sm="12" :lg="12">
  55. <el-form-item label="表头备注" prop="remark">
  56. <el-input
  57. v-model="mainForm.remark"
  58. placeholder="请输入表头备注"
  59. />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :xs="24" :sm="12" :lg="12">
  63. <el-form-item label="业务员" prop="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="itemRemark"
  350. min-width="160"
  351. >
  352. <template slot-scope="scope">
  353. <el-input v-model="scope.row.itemRemark" 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. label-position="left"
  427. size="small"
  428. >
  429. <el-row v-if="factor.length && !dataList.length" style="margin: 0 0 20px 0;font-size: 20px;">
  430. 引用销售政策说明:{{ !remark ? factor[0].name : remark }} 配提比例:{{ pop }}
  431. </el-row>
  432. <el-row v-if="factor.length && !dataList.length && factor[0].remark" style="margin: 0 0 20px 0;font-size: 20px;">
  433. 备注:{{ factor[0].remark}}
  434. </el-row>
  435. <el-row :gutter="20">
  436. <el-col :xs="24" :sm="12" :lg="11">
  437. <el-form-item label="销售政策">
  438. <el-select
  439. v-model="screenForm.policyId"
  440. placeholder="选择销售政策"
  441. filterable
  442. :disabled="disabled"
  443. style="width: 100%"
  444. @change="handlePolicy"
  445. >
  446. <el-option
  447. v-for="(item, index) in policyList"
  448. :key="index"
  449. :label="item.title"
  450. :value="item.code"
  451. />
  452. </el-select> </el-form-item>
  453. </el-col>
  454. <el-col :xs="24" :sm="8" :lg="11">
  455. <el-form-item label="型号">
  456. <el-input
  457. v-model="screenForm.specification"
  458. placeholder="请输入型号"
  459. />
  460. </el-form-item>
  461. </el-col>
  462. <el-col :xs="24" :sm="12" :lg="11">
  463. <el-form-item label="销售类型">
  464. <el-select
  465. v-model="screenForm.saleTypeCode"
  466. filterable
  467. placeholder="选择销售类型"
  468. style="width: 100%"
  469. >
  470. <el-option label="默认" :value="''" />
  471. <el-option
  472. v-for="item in ztypeList"
  473. :key="item.id"
  474. :label="item.saleName"
  475. :value="item.saleCode"
  476. />
  477. </el-select>
  478. </el-form-item>
  479. </el-col>
  480. <el-col :xs="24" :sm="12" :lg="11" class="tr">
  481. <!-- <el-button
  482. type="primary"
  483. size="small"
  484. @click="handlePolicyTypeList"
  485. >查询</el-button> -->
  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] || 0 | numToFixed}}
  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 || 0 | 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] || 0 | numToFixed}}
  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. specification:''
  786. },
  787. currentPage: 1,
  788. listTotal: 0,
  789. salesTypeList: [],
  790. typeList: [],
  791. ztypeList: [],
  792. leftGoodsList: [],
  793. rightGoodsList: [],
  794. leftSelection: [],
  795. rightSelection: [],
  796. policyList: [],
  797. xjWalletList: [],
  798. flWalletList: [],
  799. dataList: [],
  800. columns: [
  801. {
  802. prop: 'saleTypeName',
  803. lable: '销售类型',
  804. widht: 200,
  805. align:'left'
  806. },
  807. {
  808. prop: 'materialName',
  809. lable: '产品名称',
  810. widht: 200,
  811. align:'left'
  812. },
  813. {
  814. prop: 'specification',
  815. lable: '规格型号',
  816. widht: 200,
  817. align:'left'
  818. },
  819. {
  820. prop: 'qty',
  821. lable: '数量',
  822. widht: 200,
  823. num: true,
  824. align:'right'
  825. },
  826. {
  827. prop: 'price',
  828. lable: '单价',
  829. widht: 200,
  830. align:'right'
  831. },
  832. {
  833. prop: 'zong',
  834. widht: 200,
  835. lable: '金额',
  836. jie: true,
  837. align:'right'
  838. }
  839. ],
  840. listLoading: false,
  841. listLoading2: false,
  842. popDataArr: [],
  843. radioObj: {},
  844. step: 0,
  845. policyId: '',
  846. policyConditionId: '',
  847. multipleSelection: [],
  848. multipleSelections: [],
  849. multipleData: [],
  850. disabled: false,
  851. cid: '',
  852. newDataList: [],
  853. userList: [],
  854. fang: false,
  855. popfun: {},
  856. poptotal: {},
  857. popcun: {},
  858. totalQty: 0,
  859. totalPrice: 0,
  860. totalAmount: 0,
  861. totalArr: [],
  862. type: 1,
  863. newMultipleSelections: [],
  864. remark: ''
  865. }
  866. },
  867. computed: {
  868. sidebar() {
  869. // console.log(11145454);
  870. return this.$store.state.app.sidebar
  871. },
  872. classObj() {
  873. return {
  874. hideSidebar: !this.sidebar.opened,
  875. openSidebar: this.sidebar.opened
  876. }
  877. },
  878. comxjWalletList() {
  879. return (c) => {
  880. // // consloe(c, "现金钱包");
  881. const walle = []
  882. const ovalVall = c == undefined || !c.length ? [] : c
  883. for (let i = 0; i < this.xjWalletList.length; i++) {
  884. for (let j = 0; j < ovalVall.length; j++) {
  885. if (this.xjWalletList[i].walletRebateId == ovalVall[j].walletId) {
  886. walle.push(this.xjWalletList[i])
  887. }
  888. }
  889. }
  890. return walle
  891. }
  892. },
  893. comText() {
  894. return (val) => {
  895. if (this.cusIndex - 1 == 0) {
  896. const params = this.radio.split('&')
  897. return this.dataList.filter((k) => {
  898. return k.id == params[0]
  899. })[0][val]
  900. } else {
  901. const params =
  902. this.radioObj['radio' + (this.cusIndex - 1)].split('&')
  903. return this.popDataArr[this.cusIndex - 2].filter((k) => {
  904. return k.id == params[0]
  905. })[0][val]
  906. }
  907. }
  908. }
  909. // pickerOptions({ $props }) {
  910. // return {
  911. // disabledDate: (time) => {
  912. // return time.getTime() < Date.now() - 1 * 24 * 60 * 60 * 1000;
  913. // },
  914. // };
  915. // },
  916. },
  917. created() {
  918. this.getDictList()
  919. this.getWalletList()
  920. this.getWarehouseList()
  921. this.getTypeList()
  922. this.getUserList()
  923. if (this.listItem) {
  924. this.getDetail()
  925. }
  926. },
  927. methods: {
  928. blurQty(e, row) {
  929. if (!e) {
  930. this.$set(row, 'qty', 1)
  931. }
  932. },
  933. funQty(qty, row, index) {
  934. if (row.fang) {
  935. if (this.type == 1) {
  936. this.$set(this.totalArr, index, {
  937. totalQty: 0,
  938. totalPrice: 0,
  939. totalAmount: 0
  940. })
  941. let sum = 0
  942. for (let j = 0; j < this.multipleSelections[index].length; j++) {
  943. this.multipleSelections[index][j].fang = true
  944. sum += +this.multipleSelections[index][j].qty
  945. this.totalArr[index].totalPrice +=
  946. +this.multipleSelections[index][j].price
  947. this.totalArr[index].totalAmount +=
  948. +this.multipleSelections[index][j].price * (+qty )
  949. }
  950. this.totalArr[index].totalQty = sum
  951. } else {
  952. let sum = 0
  953. this.totalQty = this.totalPrice = this.totalAmount = 0
  954. for (let i = 0; i < this.multipleSelection.length; i++) {
  955. sum+= +this.multipleSelection[i].qty
  956. this.totalPrice += +this.multipleSelection[i].price
  957. this.totalAmount +=
  958. +this.multipleSelection[i].price * (+qty )
  959. }
  960. this.totalQty += sum
  961. }
  962. }
  963. },
  964. getUserList() {
  965. getUserList({
  966. pageNum: 1,
  967. pageSize: -1,
  968. adminWebsitId: '',
  969. isCustomer: 0,
  970. roleId: '',
  971. status: true,
  972. userName: ''
  973. }).then((res) => {
  974. this.userList = res.data.records
  975. // // consloe(this.userList,'122');
  976. })
  977. },
  978. handleUser(e) {
  979. const user = this.userList.filter(k => {
  980. return k.adminUserId == e
  981. })[0]
  982. this.mainForm.k3ServiceId = user.adminUserId
  983. this.mainForm.k3ServiceName = user.nickName
  984. },
  985. handleUser2(e, row) {
  986. const user = this.userList.filter(k => {
  987. return k.adminUserId == e
  988. })[0]
  989. this.$set(row, 'serviceId', user.adminUserId)
  990. this.$set(row, 'serviceName', user.nickName)
  991. this.$set(this.mainForm, 'k3ServiceId', user.adminUserId)
  992. this.$set(this.mainForm, 'k3ServiceName', user.nickName)
  993. },
  994. // 返回列表
  995. goBack() {
  996. this.$emit('backListFormDetail')
  997. },
  998. handleWallets(e, row, index) {
  999. if (e) {
  1000. const service = row.wallets.filter((k) => {
  1001. return e == k.customerWalletId
  1002. })[0]
  1003. if (index==0) {
  1004. this.$set(this.mainForm, 'k3ServiceId', service.serviceId)
  1005. this.$set(this.mainForm, 'k3ServiceName', service.serviceName)
  1006. }
  1007. this.$set(row, 'serviceId', service.serviceId)
  1008. this.$set(row, 'serviceName', service.serviceName)
  1009. // this.$set(row,'amount',service.amount || 0)
  1010. } else {
  1011. console.log(index)
  1012. if (index === 0) {
  1013. this.$set(this.mainForm, 'k3ServiceId', '')
  1014. this.$set(this.mainForm, 'k3ServiceName', '')
  1015. }
  1016. this.$set(row, 'serviceId', '')
  1017. this.$set(row, 'serviceName', '')
  1018. // this.$set(row,'amount',0 )
  1019. }
  1020. },
  1021. // 选择销售政策获取政策条件列表
  1022. async handlePolicy(e) {
  1023. this.totalArr = []
  1024. this.multipleSelections = []
  1025. this.dataList = []
  1026. this.popDataArr = []
  1027. this.screenForm.saleTypeCode = ''
  1028. const type = this.policyList.filter((k) => {
  1029. return k.code === e
  1030. })[0].type
  1031. if (type == 'PROVISION') {
  1032. // PROVISION 配提
  1033. // 选择销售政策PolidcyId改变获取条件列表
  1034. const { data } = await getPolicyConditionList({ policyId: e })
  1035. this.factor = data
  1036. this.pop = data[0].pop
  1037. this.remark = data[0].remark || ''
  1038. this.popArr = data[0].pop.split(':')
  1039. if (this.policyId) {
  1040. this.screenForm.policyId = this.policyId
  1041. if (this.listItem) {
  1042. this.policyConditionId = data[0].id
  1043. }
  1044. } else {
  1045. this.screenForm.policyId = data[0].policyId
  1046. this.policyConditionId = data[0].id
  1047. }
  1048. for (let i = 0; i < this.popArr.length; i++) {
  1049. await this.getConditionList(this.policyConditionId, i + 1)
  1050. }
  1051. } else {
  1052. // LIMIT 限量
  1053. this.getMaterialTypeList('sProvision')
  1054. }
  1055. },
  1056. hendleEdit(val, index) {
  1057. this.dialogVisible = false
  1058. // let params = {
  1059. // id: this.cid,
  1060. // theTime: this.mainForm.date,
  1061. // mainId: this.mainForm.type,
  1062. // mainName: this.mainForm.mainName,
  1063. // remark: this.mainForm.remark,
  1064. // type: 2,
  1065. // retailOrderItemList: this.goodsList,
  1066. // policyId: this.policyId,
  1067. // };
  1068. // editData(params).then((res) => {
  1069. // this.$successMsg("编辑成功");
  1070. // this.getDetail();
  1071. // });
  1072. },
  1073. // 获取条件相对应的比列
  1074. handleFactor(e) {
  1075. const data = this.factor.filter((k) => {
  1076. return k.id == e
  1077. })[0]
  1078. // // consloe(data, "kkkk");
  1079. this.pop = data.pop
  1080. this.popArr = data.pop.split(':')
  1081. this.screenForm.policyId = data.policyId
  1082. this.policyConditionId = data.id
  1083. },
  1084. // 引用销售政策搜索
  1085. async handlePolicyTypeList() {
  1086. if (this.popArr.length) {
  1087. this.popDataArr = []
  1088. this.dataList = []
  1089. for (let i = 0; i < this.popArr.length; i++) {
  1090. await this.getConditionList(this.policyConditionId, i + 1, false)
  1091. }
  1092. } else {
  1093. // sProvision = true
  1094. this.getMaterialTypeList('sProvision')
  1095. }
  1096. },
  1097. // 获取某一个比例下的数据 ,查询popType 当前 this.cusIndex+1
  1098. async getConditionList(policyConditionId, popType, fang) {
  1099. this.listLoading = true
  1100. const { data } = await getConditionList({
  1101. pageNum: this.currentPage,
  1102. pageSize: -1,
  1103. policyConditionId,
  1104. popType,
  1105. specification:this.screenForm.specification,
  1106. saleTypeCode: this.screenForm.saleTypeCode,
  1107. customerId:this.listItem ?this.listItem.customerId :'' ,
  1108. })
  1109. if (!fang) {
  1110. this.poptotal['total' + popType] = data.total
  1111. this.popcun['cun' + popType] = 1
  1112. this.popfun['handleSizeChange' + popType] = (val, index) => {
  1113. this.popcun['cun' + index] = val
  1114. this.currentPage = 1
  1115. this.getConditionList(this.policyConditionId, index, true)
  1116. }
  1117. this.popfun['handleCurrentChange' + popType] = (val, index) => {
  1118. this.popcun['cun' + index] = val
  1119. this.getConditionList(this.policyConditionId, index, true)
  1120. }
  1121. }
  1122. const datas = data.records
  1123. if (this.listItem) {
  1124. for (let i = 0; i < this.goodsList.length; i++) {
  1125. for (let j = 0; j < datas.length; j++) {
  1126. if (datas[j].id == this.goodsList[i].policyMaterialId) {
  1127. this.$set(datas[j], 'disabled', true)
  1128. }
  1129. }
  1130. }
  1131. }
  1132. // this.total = data.total;
  1133. // console.log(this.goodsList,'4555');
  1134. if (this.goodsList.length) {
  1135. for (let p = 0; p < this.goodsList.length; p++) {
  1136. for (let q = 0; q < datas.length; q++) {
  1137. if (this.goodsList[p].id == datas[q].id) {
  1138. this.$set(datas[q], 'disabled', true)
  1139. }
  1140. }
  1141. }
  1142. }
  1143. for (let i = 0; i < data.records.length; i++) {
  1144. data.records[i].qty = 1
  1145. data.records[i].policyMaterialId = data.records[i].id
  1146. this.$set(
  1147. data.records[i],
  1148. 'zong',
  1149. data.records[i].qty * data.records[i].price
  1150. )
  1151. data.records[i].sums1 = ['price', 'qty', 'zong']
  1152. // this.$set(data.records[i],'userList',this.userList)
  1153. }
  1154. if (fang) {
  1155. this.popDataArr[popType] = datas
  1156. } else {
  1157. this.popDataArr.push(datas)
  1158. }
  1159. this.totalArr.push({
  1160. totalQty: 0,
  1161. totalPrice: 0,
  1162. totalAmount: 0
  1163. })
  1164. // this.$set(this.totalArr,[...this.totalArr])
  1165. this.listLoading = false
  1166. // consloe(this.popDataArr);
  1167. },
  1168. // 获取政策列表
  1169. getMaterialTypeList(val) {
  1170. this.listLoading2 = true
  1171. getMaterialTypeList({
  1172. pageNum: 1,
  1173. pageSize: -1,
  1174. policyId: this.screenForm.policyId,
  1175. saleTypeCode: this.screenForm.saleTypeCode,
  1176. specification:this.screenForm.specification,
  1177. customerId:this.listItem ?this.listItem.customerId :'' ,
  1178. [val]: true
  1179. }).then((res) => {
  1180. this.dataList = res.data.records
  1181. if (this.listItem) {
  1182. for (let i = 0; i < this.goodsList.length; i++) {
  1183. for (let j = 0; j < this.dataList.length; j++) {
  1184. if (this.dataList[j].id == this.goodsList[i].policyMaterialId) {
  1185. this.$set(this.dataList[i], 'disabled', true)
  1186. }
  1187. }
  1188. }
  1189. }
  1190. for (let i = 0; i < res.data.records.length; i++) {
  1191. this.$set(
  1192. res.data.records[i],
  1193. 'qty',
  1194. 1
  1195. )
  1196. res.data.records[i].sums1 = ['price', 'qty', 'zong']
  1197. res.data.records[i].userList = this.userList
  1198. res.data.records[i].policyMaterialId = res.data.records[i].id
  1199. for (let j = 0; j < this.goodsList.length; j++) {
  1200. if (this.goodsList[j].id == res.data.records[i].id) {
  1201. res.data.records[i].disabled = false
  1202. }
  1203. }
  1204. }
  1205. this.dataList = res.data.records
  1206. this.total = res.data.total
  1207. this.listLoading2 = false
  1208. this.popDataArr = []
  1209. this.popArr = []
  1210. // // consloe(this.dataList, "kkkk");
  1211. })
  1212. },
  1213. // 下一步获取某个政策条件比例数据
  1214. handleCondition() {
  1215. if (this.multipleSelection.length) {
  1216. this.cusIndex += 1
  1217. this.disabled = true
  1218. this.multipleData.push(this.multipleSelection)
  1219. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1220. } else {
  1221. this.$errorMsg('请选择')
  1222. }
  1223. // // consloe(this.cusIndex,'下');
  1224. },
  1225. // 上一步
  1226. handleShang() {
  1227. this.cusIndex == 0 ? (this.disabled = false) : ''
  1228. this.multipleData.splice(this.cusIndex, 1)
  1229. this.popDataArr.splice(this.cusIndex, 1)
  1230. this.cusIndex -= 1
  1231. // // consloe(this.cusIndex,'上');
  1232. },
  1233. /**
  1234. * 根据条件禁用行复选框
  1235. * 函数返回值为false则禁用选择(反之亦然)
  1236. * @param {Object} row - 行数据
  1237. * @param {String} index - 索引值
  1238. * @return Boolean
  1239. */
  1240. selectable: function(row, index) {
  1241. // row.disabled == undefined 才能被选中
  1242. if (row.disabled == undefined) {
  1243. return true
  1244. }
  1245. // 函数必须有返回值且是布尔值
  1246. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  1247. // 如果没有返回值则默认返回false(全部无法选中)
  1248. },
  1249. /**
  1250. * 根据条件禁用行复选框
  1251. * 函数返回值为false则禁用选择(反之亦然)
  1252. * @param {Object} row - 行数据
  1253. * @param {String} index - 索引值
  1254. * @return Boolean
  1255. */
  1256. selectable2: function(row, index) {
  1257. // row.disabled == undefined 才能被选中
  1258. if (row.disabled == undefined) {
  1259. return true
  1260. }
  1261. // 函数必须有返回值且是布尔值
  1262. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  1263. // 如果没有返回值则默认返回false(全部无法选中)
  1264. },
  1265. // 条件数据多选
  1266. handleSelectionChange(val, type, index) {
  1267. if (type === 1) {
  1268. this.type = 1
  1269. if (!this.multipleSelections.length) {
  1270. this.multipleSelections = new Array(index).fill([])
  1271. } else {
  1272. for (let i = 0; i < this.multipleSelections.length; i++) {
  1273. if (!this.multipleSelections[i] || !this.multipleSelections[i].length) {
  1274. this.multipleSelections[i] = []
  1275. }
  1276. }
  1277. }
  1278. this.$set(this.multipleSelections, index, val)
  1279. this.$set(this.totalArr, index, {
  1280. totalQty: 0,
  1281. totalPrice: 0,
  1282. totalAmount: 0
  1283. })
  1284. for (let j = 0; j < this.multipleSelections[index].length; j++) {
  1285. this.multipleSelections[index][j].fang = true
  1286. this.totalArr[index].totalQty +=
  1287. +this.multipleSelections[index][j].qty
  1288. this.totalArr[index].totalPrice +=
  1289. +this.multipleSelections[index][j].price
  1290. this.totalArr[index].totalAmount +=
  1291. +this.multipleSelections[index][j].price *
  1292. +this.multipleSelections[index][j].qty
  1293. }
  1294. // consloe(this.multipleSelections);
  1295. } else {
  1296. this.type = 2
  1297. this.multipleSelection = val
  1298. console.log(this.multipleSelection)
  1299. this.totalQty = this.totalPrice = this.totalAmount = 0
  1300. for (let i = 0; i < this.multipleSelection.length; i++) {
  1301. this.multipleSelection[i].fang = true
  1302. this.totalQty += +this.multipleSelection[i].qty
  1303. this.totalPrice += +this.multipleSelection[i].price
  1304. this.totalAmount +=
  1305. +this.multipleSelection[i].price *
  1306. +this.multipleSelection[i].qty
  1307. }
  1308. }
  1309. },
  1310. hanlePopData() {
  1311. console.log(this.multipleSelections)
  1312. this.multipleData.push(this.multipleSelection)
  1313. if (this.multipleData.length && this.multipleSelection.length) {
  1314. let arrData = []
  1315. for (let i = 0; i < this.multipleData.length; i++) {
  1316. if (this.multipleData[i].wallets && this.multipleData[i].wallets.length) {
  1317. this.$set(this.multipleData[i], 'customerWalletId', this.multipleData[i].wallets[0].customerWalletId)
  1318. this.$set(this.multipleData[i], 'serviceName', this.multipleData[i].wallets[0].serviceName)
  1319. this.$set(this.multipleData[i], 'serviceId', this.multipleData[i].wallets[0].serviceId)
  1320. this.$set(this.multipleData[i],'amount', 0.00)
  1321. }
  1322. arrData = [...arrData, ...this.multipleData[i]]
  1323. }
  1324. if (this.goodsList.length) {
  1325. this.goodsList = [...this.goodsList, ...arrData]
  1326. } else {
  1327. this.goodsList = arrData
  1328. }
  1329. if (this.dataList.length) {
  1330. for (let u = 0; u < this.goodsList.length; u++) {
  1331. this.goodsList[u].disabled = true
  1332. }
  1333. this.newDataList = this.multipleSelection
  1334. this.disabled = true
  1335. }
  1336. this.goodsList.forEach((item) => {
  1337. this.$set(item, 'status1', '')
  1338. this.$set(item, 'status2', '')
  1339. this.$set(item, 'userList', this.userList)
  1340. })
  1341. if (this.goodsList.length && this.goodsList[0].wallets.length) {
  1342. console.log(555555)
  1343. this.mainForm.k3ServiceName =
  1344. this.goodsList[0].wallets[0].serviceName || ''
  1345. this.mainForm.k3ServiceId =
  1346. this.goodsList[0].wallets[0].serviceId || ''
  1347. }
  1348. // if (this.goodsList.length>4) {
  1349. // this.newGoodsList = this.goodsList
  1350. // this.newGoodsList.length = 4
  1351. // }
  1352. this.cusIndex = 0
  1353. this.total = 0
  1354. this.popDataArr = []
  1355. this.multipleData = []
  1356. this.multipleSelection = []
  1357. this.policyId = this.screenForm.policyId
  1358. this.totalQty = this.totalPrice = this.totalAmount = 0
  1359. this.isShowDialog = false
  1360. this.$refs.singleTable.clearSelection()
  1361. // consloe(this.goodsList, "kkkk");
  1362. } else if (this.multipleSelections.length) {
  1363. let arrData = []
  1364. this.newMultipleSelections = this.multipleSelections
  1365. for (let i = 0; i < this.multipleSelections.length; i++) {
  1366. for (let j = 0; j < this.multipleSelections[i].length; j++) {
  1367. this.multipleSelections[i][j].disabled = true
  1368. if (this.multipleSelections[i][j].wallets.length) {
  1369. this.$set(this.multipleSelections[i][j], 'customerWalletId', this.multipleSelections[i][j].wallets[0].customerWalletId)
  1370. this.$set(this.multipleSelections[i][j], 'serviceName', this.multipleSelections[i][j].wallets[0].serviceName)
  1371. this.$set(this.multipleSelections[i][j], 'serviceId', this.multipleSelections[i][j].wallets[0].serviceId)
  1372. this.$set(this.multipleSelections[i][j],'amount',0.00)
  1373. }
  1374. arrData = [...arrData, this.multipleSelections[i][j]]
  1375. }
  1376. }
  1377. if (this.goodsList.length) {
  1378. this.goodsList = [...this.goodsList, ...arrData]
  1379. } else {
  1380. this.goodsList = arrData
  1381. }
  1382. if (this.goodsList.length && this.goodsList[0].wallets.length) {
  1383. this.mainForm.k3ServiceName =
  1384. this.goodsList[0].wallets[0].serviceName || ''
  1385. this.mainForm.k3ServiceId =
  1386. this.goodsList[0].wallets[0].serviceId || ''
  1387. }
  1388. this.goodsList.forEach((item) => {
  1389. this.$set(item, 'status1', '')
  1390. this.$set(item, 'status2', '')
  1391. this.$set(item, 'userList', this.userList)
  1392. })
  1393. this.disabled = true
  1394. // this.popDataArr = [];
  1395. this.multipleData = []
  1396. this.multipleSelection = []
  1397. this.policyId = this.screenForm.policyId
  1398. this.totalQty = this.totalPrice = this.totalAmount = 0
  1399. this.isShowDialog = false
  1400. this.$refs.singleTable.forEach((k) => {
  1401. k.clearSelection()
  1402. })
  1403. // this.$refs.singleTable.clearSelection();
  1404. } else {
  1405. this.$errorMsg('请选择')
  1406. }
  1407. },
  1408. // 获取详情
  1409. getDetail() {
  1410. getUserList({
  1411. pageNum: 1,
  1412. pageSize: -1,
  1413. adminWebsitId: '',
  1414. isCustomer: 0,
  1415. roleId: '',
  1416. status: true,
  1417. userName: ''
  1418. }).then((res) => {
  1419. this.userList = res.data.records
  1420. getDetail({ id: this.listItem.id }).then(res => {
  1421. const data = res.data
  1422. this.mainForm.date = data.theTime
  1423. this.mainForm.type = data.mainId
  1424. this.mainForm.remark = data.remark
  1425. this.mainForm.policyId = data.policyId
  1426. this.policyId = data.policyId
  1427. this.mainForm.k3ServiceName = data.k3ServiceName
  1428. this.mainForm.k3ServiceId = data.k3ServiceId
  1429. // this.mainForm.k3ServiceName = data.retailOrderItemList[0].wallets[0].serviceName
  1430. // this.mainForm.k3ServiceId = data.retailOrderItemList[0].wallets[0].serviceId
  1431. data.retailOrderItemList.forEach((item) => {
  1432. item.status1 = ''
  1433. item.status2 = ''
  1434. this.$set(item, 'userList', this.userList)
  1435. item.rebateWallets.forEach(j=>{
  1436. if (j.customerWalletId2 === data.customerWalletId2) {
  1437. this.$set(item, 'amount', j.amount||0.00)
  1438. }
  1439. })
  1440. item.wallets.forEach((k) => {
  1441. if (k.customerWalletId === data.customerWalletId) {
  1442. this.$set(item, 'serviceId', k.serviceId)
  1443. this.$set(item, 'serviceName', k.serviceName)
  1444. }
  1445. })
  1446. })
  1447. this.goodsList = data.retailOrderItemList
  1448. })
  1449. })
  1450. },
  1451. // 获取销售政策
  1452. getPolicyList() {
  1453. policyList({
  1454. pageNum: 1,
  1455. pageSize: -1,
  1456. customerId:this.listItem ?this.listItem.customerId :'' ,
  1457. status: true
  1458. }).then((res) => {
  1459. if (this.policyId) {
  1460. this.screenForm.policyId = this.policyId
  1461. this.disabled = true
  1462. } else {
  1463. this.screenForm.policyId = res.data.records[0].code
  1464. }
  1465. this.policyList = res.data.records
  1466. if (this.policyList.length) {
  1467. this.handlePolicy(this.screenForm.policyId)
  1468. }
  1469. })
  1470. },
  1471. // 获取销售类型
  1472. getTypeList() {
  1473. const params = {
  1474. pageNum: 1,
  1475. pageSize: -1,
  1476. saleCode: '',
  1477. saleName: '',
  1478. status: ''
  1479. }
  1480. typeList(params).then((res) => {
  1481. this.ztypeList = res.data.records
  1482. // // consloe(this.ztypeList, "type1111");
  1483. })
  1484. },
  1485. // 获取仓库列表
  1486. getWarehouseList() {
  1487. getWarehouseList({
  1488. pageNum: 1,
  1489. pageSize: -1
  1490. }).then((res) => {
  1491. this.warehouseList = res.data.records
  1492. })
  1493. },
  1494. // 获取限定机型
  1495. getpolicyTypeList() {
  1496. getpolicyTypeList({
  1497. pageNum: 1,
  1498. pageSize: 10,
  1499. policyId: this.screenForm.policyId,
  1500. saleTypeCode: this.screenForm.saleTypeCode
  1501. }).then((res) => {
  1502. for (let i = 0; i < res.data.records.length; i++) {
  1503. this.$set(
  1504. res.data.records[i],
  1505. 'qty',
  1506. 1
  1507. )
  1508. res.data.records[i].sums2 = ['price', 'qty', 'zong']
  1509. res.data.records[i].userList = this.userList
  1510. }
  1511. this.dataList = res.data.records
  1512. this.total = res.data.total
  1513. })
  1514. },
  1515. // 打开引用
  1516. handleShow() {
  1517. this.isShowDialog = true
  1518. this.getPolicyList()
  1519. },
  1520. // 获取钱包列表
  1521. getWalletList() {
  1522. getWalletList({
  1523. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  1524. type: 'COMMONLY'
  1525. }).then((res) => {
  1526. this.xjWalletList = res.data
  1527. })
  1528. getWalletList({
  1529. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  1530. type: 'REBATE'
  1531. }).then((res) => {
  1532. this.flWalletList = res.data
  1533. })
  1534. },
  1535. // 获取销售类型列表
  1536. getSalesTypeList() {
  1537. getSalesTypeList({
  1538. pageNum: 1,
  1539. pageSize: -1
  1540. }).then((res) => {
  1541. this.salesTypeList = res.data.records
  1542. })
  1543. },
  1544. getDictList() {
  1545. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then((res) => {
  1546. this.typeList = res.data
  1547. })
  1548. },
  1549. // 获取商品列表
  1550. getGoodsList() {
  1551. getGoodsList({
  1552. pageNum: this.currentPage,
  1553. pageSize: 10,
  1554. mainId: this.screenForm.type,
  1555. saleId: this.screenForm.salesType,
  1556. materialCode: this.screenForm.proNum,
  1557. materialName: this.screenForm.proName,
  1558. specification: this.screenForm.proModel,
  1559. price1: this.screenForm.price1,
  1560. price2: this.screenForm.price2
  1561. }).then((res) => {
  1562. const oldGoodsList = this.goodsList
  1563. const newGoodsList = res.data.records
  1564. for (let i = 0; i < oldGoodsList.length; i++) {
  1565. const oldItem = oldGoodsList[i]
  1566. for (let j = 0; j < newGoodsList.length; j++) {
  1567. const newItem = newGoodsList[j]
  1568. if (newItem.materialId === oldItem.materialId) {
  1569. newGoodsList[j].selected = true
  1570. break
  1571. }
  1572. }
  1573. }
  1574. res.data.records.forEach((item) => {
  1575. item.materialName = item.name
  1576. item.materialCode = item.number
  1577. item.saleTypeName = item.saleName
  1578. item.unit = item.baseUnit
  1579. item.price = item.batchPrice
  1580. item.tax = item.taxRate
  1581. item.isDirectTransfer = false
  1582. item.directTransferQty = ''
  1583. item.status1 = ''
  1584. item.status2 = ''
  1585. item.rebateAmount = ''
  1586. item.rebateRate = ''
  1587. item.productPriceId = item.id
  1588. })
  1589. this.leftGoodsList = res.data.records
  1590. this.listTotal = res.data.total
  1591. })
  1592. },
  1593. // 查询重复值并禁选
  1594. checkboxSelect(row, rowIndex) {
  1595. if (row.selected) {
  1596. return false // 禁用
  1597. } else {
  1598. return true // 不禁用
  1599. }
  1600. },
  1601. // 点击 选择商品
  1602. openDialog() {
  1603. this.getSalesTypeList()
  1604. this.getGoodsList()
  1605. this.isShowDialog = true
  1606. },
  1607. // 提交筛选表单
  1608. submitScreenForm() {
  1609. this.currentPage = 1
  1610. this.getGoodsList()
  1611. },
  1612. // 重置筛选表单
  1613. resetScreenForm() {
  1614. this.$refs.screenForm.resetFields()
  1615. this.currentPage = 1
  1616. this.getGoodsList()
  1617. },
  1618. // 关闭 弹窗
  1619. closeDialog() {
  1620. this.isShowDialog = false
  1621. this.popDataArr = []
  1622. },
  1623. // 删除
  1624. deleteGoods() {
  1625. const rightGoodsList = this.rightGoodsList
  1626. const rightSelection = this.rightSelection
  1627. for (let i = 0; i < rightGoodsList.length; i++) {
  1628. for (let j = 0; j < rightSelection.length; j++) {
  1629. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1630. this.rightGoodsList.splice(i, 1)
  1631. }
  1632. }
  1633. }
  1634. },
  1635. // 确定 添加产品
  1636. submitAddGoods() {
  1637. if (this.radio) {
  1638. const params = this.radio.split('&')
  1639. this.screenForm.policyId = params[1]
  1640. this.mainForm.policyId = params[1]
  1641. this.cusIndex += 1
  1642. getpolicyList({
  1643. materialId: params[2],
  1644. policyId: params[1]
  1645. }).then((res) => {
  1646. this.pop = res.data.pop
  1647. this.popArr = res.data.pop.split(':')
  1648. this.popArr.splice(0, 1)
  1649. for (let i = 0; i < this.popArr.length; i++) {
  1650. this.$set(this.radioObj, 'radio' + (i + 1), '')
  1651. }
  1652. this.step = this.cusIndex + 1
  1653. this.getConditionList(params[3], this.step)
  1654. })
  1655. } else {
  1656. this.$errorMsg('请选择')
  1657. }
  1658. },
  1659. // 更改每页数量
  1660. handleSizeChange(val) {
  1661. this.pageSize = val
  1662. this.currentPage = 1
  1663. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1664. },
  1665. // 更改当前页
  1666. handleCurrentChange(val) {
  1667. this.currentPage = val
  1668. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1669. },
  1670. // 更改列表当前页
  1671. handleTableCurrentChange(val) {
  1672. this.currentPage = val
  1673. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1674. },
  1675. handleClose() {
  1676. this.totalQty = this.totalPrice = this.totalAmount = 0
  1677. // this.dataList = [];
  1678. // this.popDataArr = [];
  1679. // this.screenForm.policyId = "";
  1680. // this.screenForm.saleTypeCode = "";
  1681. },
  1682. // 删除产品
  1683. deleteItem(index, id) {
  1684. this.goodsList.splice(index, 1)
  1685. // this.dataList
  1686. this.newDataList.splice(index, 1)
  1687. if (!this.goodsList.length) {
  1688. this.disabled = false
  1689. this.policyId = ''
  1690. this.mainForm.policyId = ''
  1691. }
  1692. // this.popDataArr.splice(index,1)
  1693. },
  1694. // 修改返利钱包
  1695. changeWallet(e, row) {
  1696. if (e) {
  1697. const obj = row.rebateWallets.filter(k => {
  1698. return e === k.customerWalletId
  1699. })[0]
  1700. this.$set(row, 'rebateRate', (obj.rebateRate || 0))
  1701. this.$set(row,'amount',obj.amount || 0.00)
  1702. } else {
  1703. this.$set(row, 'rebateRate', 0)
  1704. this.$set(row,'amount',0.00)
  1705. }
  1706. },
  1707. clearWallet(e) {
  1708. console.log(e)
  1709. // const obj = row.rebateWallets.filter(k => {
  1710. // return e === k.customerWalletId
  1711. // })[0]
  1712. this.$set(row, 'rebateRate', 0)
  1713. },
  1714. // 检查库存
  1715. checkStock() {
  1716. if (!this.warehouseValue) {
  1717. return this.$errorMsg('请选择仓库')
  1718. }
  1719. if (!this.goodsList) {
  1720. return this.$errorMsg('请添加货品')
  1721. }
  1722. const ids = []
  1723. this.goodsList.forEach((item) => {
  1724. ids.push(item.materialId)
  1725. })
  1726. checkStock({
  1727. correspondId: this.warehouseValue,
  1728. materialId: ids.join(',')
  1729. }).then((res) => {
  1730. if (res.data) {
  1731. this.goodsList.forEach((item, index) => {
  1732. item.status1 = res.data[index].allStockNum
  1733. item.status2 = res.data[index].stockNum
  1734. // // consloe(item.status1, item.status2);
  1735. })
  1736. }
  1737. })
  1738. },
  1739. status2Filter(item) {
  1740. if (
  1741. item.status2 === '' ||
  1742. item.status2 === null ||
  1743. item.status2 === undefined
  1744. ) return '未检查' ;
  1745. if ( item.status2 <= 0 ) {
  1746. return '无货'
  1747. }else if(item.status2 >= 1 && item.status2 <= 30){
  1748. return '紧缺'
  1749. }else if(item.status2 >=31 && item.status2 <= 1000 ){
  1750. return '有货'
  1751. }else{
  1752. return '充足'
  1753. }
  1754. // else if (item.status2 >= item.qty) return '可用'
  1755. // else return '短缺'
  1756. },
  1757. // 保存
  1758. clickSubmitForm() {
  1759. this.$refs.mainForm.validate((valid) => {
  1760. if (valid) {
  1761. // let mainName =
  1762. // this.typeList[
  1763. // findElem(this.typeList, "dictCode", this.mainForm.type)
  1764. // ].dictValue;
  1765. const params = {
  1766. theTime: this.mainForm.date,
  1767. k3ServiceId: this.mainForm.k3ServiceId,
  1768. k3ServiceName: this.mainForm.k3ServiceName,
  1769. remark: this.mainForm.remark,
  1770. type: 2, // 1:普通零售单,2:政策零售单
  1771. retailOrderItemList: this.goodsList,
  1772. policyId: this.policyId
  1773. }
  1774. console.log(params)
  1775. if (this.listItem) {
  1776. params.id = this.listItem.id
  1777. editData(params).then((res) => {
  1778. this.$successMsg('编辑成功')
  1779. this.goBack()
  1780. this.$parent.getList()
  1781. })
  1782. } else {
  1783. addData(params).then((res) => {
  1784. this.$successMsg('添加成功')
  1785. this.goBack()
  1786. this.$parent.getList()
  1787. })
  1788. }
  1789. }
  1790. })
  1791. }
  1792. }
  1793. }
  1794. </script>
  1795. <style scoped lang="scss">
  1796. .yinput{
  1797. ::v-deep .el-input__inner{
  1798. text-align: right;
  1799. }
  1800. }
  1801. .fr {
  1802. margin: 10px;
  1803. overflow: hidden;
  1804. }
  1805. .detail-container {
  1806. width: 100%;
  1807. height: 100%;
  1808. margin-bottom:80px;
  1809. ::v-deep .el-table__append-wrapper{
  1810. overflow: initial;
  1811. }
  1812. }
  1813. .table{
  1814. margin-top: 20px 0 0 0;
  1815. background-color: rgb(237 237 237);
  1816. }
  1817. .page-footer .footer.hideSidebar{
  1818. margin-left: 0;
  1819. width: 100%;
  1820. }
  1821. .mybox {
  1822. padding: 20px 0;
  1823. text-align: right;
  1824. div:first-child {
  1825. flex: 0 0 55px;
  1826. }
  1827. div {
  1828. flex: 1 0 200px;
  1829. padding-right: 10px;
  1830. text-align: right;
  1831. }
  1832. }
  1833. .main-title {
  1834. display: flex;
  1835. justify-content: space-between;
  1836. align-items: center;
  1837. margin-top: 20px;
  1838. height: 60px;
  1839. border-bottom: 1px solid #dcdfe6;
  1840. margin-bottom: 20px;
  1841. .title {
  1842. font-size: 16px;
  1843. font-weight: 600;
  1844. padding-left: 10px;
  1845. }
  1846. }
  1847. .tables {
  1848. display: flex;
  1849. margin-top: 10px;
  1850. .table {
  1851. width: 45%;
  1852. }
  1853. .buttons {
  1854. display: flex;
  1855. flex-direction: column;
  1856. justify-content: center;
  1857. align-items: center;
  1858. padding: 0 10px;
  1859. button {
  1860. margin: 0;
  1861. margin-top: 10px;
  1862. }
  1863. }
  1864. }
  1865. .ellipsis {
  1866. overflow: hidden;
  1867. text-overflow: ellipsis;
  1868. white-space: nowrap;
  1869. }
  1870. </style>