retail_form2.vue 38 KB

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