retail_form.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  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
  8. ref="mainForm"
  9. :model="mainForm"
  10. :rules="mainFormRules"
  11. label-width="100px"
  12. size="small"
  13. label-position="right"
  14. >
  15. <el-row :gutter="20">
  16. <el-col :xs="24" :sm="12" :lg="8">
  17. <el-form-item label="订单号" prop="orderNum">
  18. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  22. <el-form-item label="单据日期" prop="date">
  23. <el-date-picker
  24. v-model="mainForm.date"
  25. disabled
  26. type="date"
  27. value-format="yyyy-MM-dd"
  28. style="width: 100%"
  29. placeholder="系统自动生成"
  30. >
  31. </el-date-picker>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :xs="24" :sm="12" :lg="8">
  35. <el-form-item label="业务员" prop="salesMan">
  36. <el-select
  37. v-model="mainForm.salesMan"
  38. placeholder="选择业务员"
  39. size="small"
  40. filterable
  41. clearable
  42. style="width: 100%"
  43. >
  44. <el-option
  45. v-for="item in salesmanList"
  46. :key="item.adminUserId"
  47. :label="item.nickName"
  48. :value="item.adminUserId"
  49. >
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. <el-row :gutter="20">
  56. <el-col :xs="24" :sm="12" :lg="8">
  57. <el-form-item label="经销商编码" prop="jxsNum">
  58. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :xs="24" :sm="12" :lg="16">
  62. <el-form-item label="经销商名称" prop="jxsName">
  63. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" disabled></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :xs="24" :sm="12" :lg="8">
  67. <el-form-item label="文件编号" prop="fileNum">
  68. <el-input v-model="mainForm.fileNum" placeholder="请输入文件编号"></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :xs="24" :sm="12" :lg="16">
  72. <el-form-item label="表头备注" prop="remark">
  73. <el-input v-model="mainForm.remark" placeholder="请输入表头备注"></el-input>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. </el-form>
  78. <div class="main-title">
  79. <div class="title">货品信息</div>
  80. <div>
  81. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  82. <el-option
  83. :label="item.name"
  84. :value="item.id"
  85. v-for="(item, index) in warehouseList"
  86. :key="index"
  87. ></el-option>
  88. </el-select>
  89. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  90. <el-divider direction="vertical"></el-divider>
  91. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  92. </div>
  93. </div>
  94. <div class="table" style="margin-top: 20px">
  95. <el-table
  96. :data="goodsList"
  97. element-loading-text="Loading"
  98. border
  99. fit
  100. highlight-current-row
  101. stripe
  102. max-height="400"
  103. show-summary
  104. :summary-method="$getSummaries"
  105. >
  106. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  107. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="140" show-overflow-tooltip>
  108. <template slot-scope="scope">
  109. <el-select
  110. v-model="scope.row.saleTypeId"
  111. placeholder="选择销售类型"
  112. size="mini"
  113. clearable
  114. style="width: 100%"
  115. @change="changeSaleType(scope.$index)"
  116. v-if="listItem"
  117. >
  118. <el-option
  119. v-for="item in salesTypeList"
  120. :key="item.id"
  121. :label="item.saleName"
  122. :value="item.id"
  123. ></el-option>
  124. </el-select>
  125. <div v-else>{{ scope.row.saleTypeName }}</div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column
  129. align="center"
  130. label="物料编码"
  131. prop="materialCode"
  132. min-width="120"
  133. show-overflow-tooltip
  134. ></el-table-column>
  135. <el-table-column
  136. align="center"
  137. label="产品编码"
  138. prop="materialOldNumber"
  139. min-width="120"
  140. show-overflow-tooltip
  141. ></el-table-column>
  142. <el-table-column
  143. align="center"
  144. label="产品名称"
  145. prop="materialName"
  146. min-width="160"
  147. show-overflow-tooltip
  148. ></el-table-column>
  149. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  150. <template slot-scope="scope">
  151. <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
  152. <div v-else>{{ scope.row.specification }}</div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column
  156. align="center"
  157. label="单位"
  158. prop="unit"
  159. min-width="100"
  160. show-overflow-tooltip
  161. ></el-table-column>
  162. <!-- <el-table-column align="left" label="文件编号" prop="fileNo" min-width="200" show-overflow-tooltip>
  163. <template slot-scope="scope">
  164. <el-input v-model="scope.row.fileNo" size="small" ></el-input>
  165. </template>
  166. </el-table-column> -->
  167. <el-table-column align="right" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  168. <template slot-scope="scope">
  169. <el-input
  170. v-model="scope.row.price"
  171. size="small"
  172. type="number"
  173. @mousewheel.native.prevent
  174. v-if="listItem && !isDealer"
  175. ></el-input>
  176. <div v-else>{{ scope.row.price | numToFixed }}</div>
  177. </template>
  178. </el-table-column>
  179. <el-table-column align="right" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  180. <template slot-scope="scope">
  181. <el-input v-model="scope.row.qty" size="small" type="number" @mousewheel.native.prevent></el-input>
  182. </template>
  183. </el-table-column>
  184. <el-table-column align="right" label="订单金额" prop="compute_amount" min-width="100" show-overflow-tooltip>
  185. <template slot-scope="scope">
  186. {{ (scope.row.price * scope.row.qty) | numToFixed }}
  187. </template>
  188. </el-table-column>
  189. <el-table-column align="center" label="返利类型" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  190. <template slot-scope="scope">
  191. <el-select
  192. v-model="scope.row.customerWalletId2"
  193. placeholder="选择返利类型"
  194. size="small"
  195. clearable
  196. @change="changeWallet(scope.$index)"
  197. >
  198. <el-option
  199. v-for="item in scope.row.rebateWallets"
  200. :key="item.customerWalletId"
  201. :label="item.customerWalletName"
  202. :value="item.customerWalletId"
  203. >
  204. </el-option>
  205. </el-select>
  206. </template>
  207. </el-table-column>
  208. <el-table-column align="right" label="可用返利" prop="rebateAmount" min-width="100" show-overflow-tooltip>
  209. <template slot-scope="scope">
  210. {{ scope.row.rebateAmount | numToFixed }}
  211. </template>
  212. </el-table-column>
  213. <el-table-column
  214. align="right"
  215. label="使用返利金额"
  216. prop="compute_flAmount"
  217. min-width="120"
  218. show-overflow-tooltip
  219. >
  220. <template slot-scope="scope">
  221. {{
  222. (((scope.row.price - scope.row.discAmount) * scope.row.qty * (scope.row.rebateRate * 100)) / 100)
  223. | numToFixed
  224. }}
  225. </template>
  226. </el-table-column>
  227. <el-table-column align="right" label="格力折扣" prop="compute_zkAmount" min-width="100" show-overflow-tooltip>
  228. <template slot-scope="scope">
  229. {{ (scope.row.qty * scope.row.discAmount) | numToFixed }}
  230. </template>
  231. </el-table-column>
  232. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  233. <template slot-scope="scope">
  234. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable>
  235. <el-option
  236. v-for="item in scope.row.wallets"
  237. :key="item.customerWalletId"
  238. :label="item.customerWalletName"
  239. :value="item.customerWalletId"
  240. >
  241. </el-option>
  242. </el-select>
  243. </template>
  244. </el-table-column>
  245. <el-table-column align="right" label="实付金额" prop="compute_sfAmount" min-width="100" show-overflow-tooltip>
  246. <template slot-scope="scope">
  247. {{
  248. ((scope.row.price * scope.row.qty * 100 -
  249. (((scope.row.price - scope.row.discAmount) * scope.row.qty * (scope.row.rebateRate * 100)) / 100) *
  250. 100 -
  251. ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) /
  252. 100)
  253. | numToFixed
  254. }}
  255. </template>
  256. </el-table-column>
  257. <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
  258. <template slot-scope="scope">
  259. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  260. </template>
  261. </el-table-column>
  262. <el-table-column align="right" label="直调数量" prop="directTransferQty" min-width="100"></el-table-column>
  263. <el-table-column align="center" label="备注" prop="remark" min-width="160">
  264. <template slot-scope="scope">
  265. <el-input v-model="scope.row.remark" size="small"></el-input>
  266. </template>
  267. </el-table-column>
  268. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  269. <!-- <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip v-if="!listItem">
  270. <template slot-scope="scope">
  271. <div>{{ scope.row.status1 | status1Filter }}</div>
  272. </template>
  273. </el-table-column> -->
  274. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip>
  275. <template slot-scope="scope">
  276. <div>{{ status2Filter(scope.row) }}</div>
  277. </template>
  278. </el-table-column>
  279. <!-- <el-table-column align="center" label="业务员" prop="serviceId" min-width="160" show-overflow-tooltip>
  280. <template slot-scope="scope">
  281. <el-select v-model="scope.row.serviceId" placeholder="选择业务员" size="small" clearable disabled>
  282. <el-option
  283. v-for="item in salesmanList"
  284. :key="item.adminUserId"
  285. :label="item.nickName"
  286. :value="item.adminUserId">
  287. </el-option>
  288. </el-select>
  289. </template>
  290. </el-table-column> -->
  291. <el-table-column align="center" label="操作" width="100" fixed="right">
  292. <template slot-scope="scope">
  293. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  294. </template>
  295. </el-table-column>
  296. </el-table>
  297. </div>
  298. <div class="page-footer">
  299. <div class="footer">
  300. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  301. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px">
  302. <el-button slot="reference">返回列表</el-button>
  303. </el-popconfirm>
  304. </div>
  305. </div>
  306. <el-dialog v-drag title="添加产品" :visible.sync="isShowDialog" width="80%" :modal="false">
  307. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left">
  308. <el-row :gutter="20">
  309. <el-col :xs="12" :sm="6" :lg="6">
  310. <el-form-item prop="salesType">
  311. <el-select v-model="screenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  312. <el-option
  313. v-for="item in salesTypeList"
  314. :key="item.id"
  315. :label="item.saleName"
  316. :value="item.id"
  317. ></el-option>
  318. </el-select>
  319. </el-form-item>
  320. </el-col>
  321. <el-col :xs="12" :sm="6" :lg="6">
  322. <el-form-item prop="proNum">
  323. <el-input v-model="screenForm.proNum" placeholder="请输入物料编码"></el-input>
  324. </el-form-item>
  325. </el-col>
  326. <el-col :xs="12" :sm="6" :lg="6">
  327. <el-form-item prop="proName">
  328. <el-input v-model="screenForm.proName" placeholder="请输入产品名称"></el-input>
  329. </el-form-item>
  330. </el-col>
  331. <el-col :xs="12" :sm="6" :lg="6">
  332. <el-form-item prop="proModel">
  333. <el-input v-model="screenForm.proModel" placeholder="请输入产品型号"></el-input>
  334. </el-form-item>
  335. </el-col>
  336. <el-col :xs="12" :sm="6" :lg="6">
  337. <el-form-item prop="price1" style="display: flex">
  338. <el-input v-model="screenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
  339. <span> - </span>
  340. <el-input v-model="screenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
  341. </el-form-item>
  342. </el-col>
  343. <el-col :xs="12" :sm="12" :lg="18" class="tr">
  344. <el-form-item label="">
  345. <el-button size="small" @click="resetScreenForm">清空</el-button>
  346. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  347. </el-form-item>
  348. </el-col>
  349. </el-row>
  350. </el-form>
  351. <div class="tables">
  352. <div class="table">
  353. <el-table
  354. :data="leftGoodsList"
  355. element-loading-text="Loading"
  356. border
  357. fit
  358. highlight-current-row
  359. stripe
  360. height="400"
  361. @selection-change="leftSelectionChange"
  362. >
  363. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect"></el-table-column>
  364. <el-table-column
  365. align="center"
  366. label="物料编码"
  367. prop="materialNumber"
  368. min-width="120"
  369. show-overflow-tooltip
  370. ></el-table-column>
  371. <el-table-column
  372. align="center"
  373. label="产品编码"
  374. prop="materialOldNumber"
  375. min-width="120"
  376. show-overflow-tooltip
  377. ></el-table-column>
  378. <el-table-column
  379. align="center"
  380. label="产品名称"
  381. prop="name"
  382. min-width="160"
  383. show-overflow-tooltip
  384. ></el-table-column>
  385. <el-table-column
  386. align="center"
  387. label="产品型号"
  388. prop="specification"
  389. min-width="160"
  390. show-overflow-tooltip
  391. ></el-table-column>
  392. <el-table-column
  393. align="center"
  394. label="产品价格"
  395. prop="batchPrice"
  396. min-width="80"
  397. show-overflow-tooltip
  398. ></el-table-column>
  399. <el-table-column
  400. align="center"
  401. label="销售类型"
  402. prop="saleName"
  403. min-width="80"
  404. show-overflow-tooltip
  405. ></el-table-column>
  406. </el-table>
  407. <div class="pagination clearfix" style="margin-top: 10px">
  408. <div class="fr">
  409. <el-pagination
  410. @current-change="handleTableCurrentChange"
  411. :current-page="currentPage"
  412. :page-size="10"
  413. background
  414. layout="prev, pager, next"
  415. :total="listTotal"
  416. >
  417. </el-pagination>
  418. </div>
  419. </div>
  420. </div>
  421. <div class="buttons">
  422. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  423. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  424. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  425. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  426. </div>
  427. <div class="table">
  428. <el-table
  429. :data="rightGoodsList"
  430. element-loading-text="Loading"
  431. border
  432. fit
  433. highlight-current-row
  434. stripe
  435. height="400"
  436. @selection-change="rightSelectionChange"
  437. >
  438. <el-table-column align="center" type="selection" width="55"></el-table-column>
  439. <el-table-column
  440. align="center"
  441. label="销售类型"
  442. prop="saleName"
  443. min-width="80"
  444. show-overflow-tooltip
  445. ></el-table-column>
  446. <el-table-column
  447. align="center"
  448. label="物料编码"
  449. prop="materialNumber"
  450. min-width="120"
  451. show-overflow-tooltip
  452. ></el-table-column>
  453. <el-table-column
  454. align="center"
  455. label="产品编码"
  456. prop="materialOldNumber"
  457. min-width="120"
  458. show-overflow-tooltip
  459. ></el-table-column>
  460. <el-table-column
  461. align="center"
  462. label="产品名称"
  463. prop="name"
  464. min-width="160"
  465. show-overflow-tooltip
  466. ></el-table-column>
  467. <el-table-column
  468. align="center"
  469. label="产品型号"
  470. prop="specification"
  471. min-width="160"
  472. show-overflow-tooltip
  473. ></el-table-column>
  474. <el-table-column
  475. align="center"
  476. label="产品价格"
  477. prop="batchPrice"
  478. min-width="80"
  479. show-overflow-tooltip
  480. ></el-table-column>
  481. </el-table>
  482. </div>
  483. </div>
  484. <span slot="footer" class="dialog-footer">
  485. <el-button @click="closeDialog">取 消</el-button>
  486. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  487. </span>
  488. </el-dialog>
  489. </div>
  490. </template>
  491. <script>
  492. import {
  493. addData,
  494. checkStock,
  495. editData,
  496. getDetail,
  497. getGoodsList,
  498. getSalesTypeList,
  499. getWarehouseList
  500. } from '@/api/supply/retail'
  501. import { getDictList, getSalesmanList } from '@/api/common'
  502. import { findElem } from '@/utils/util'
  503. let that
  504. export default {
  505. name: 'RetailForm',
  506. componentName: 'RetailForm',
  507. props: ['listItem'],
  508. filters: {
  509. status1Filter(val) {
  510. let STOCK_ORDER_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_START').dictValue
  511. let STOCK_ORDER_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_END').dictValue
  512. let STOCK_ORDER_HAVE_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_START').dictValue
  513. let STOCK_ORDER_HAVE_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_END').dictValue
  514. let STOCK_ORDER_ALL_NUM = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_ALL_NUM').dictValue
  515. if (val === '' || val === null || val === undefined) return '未检查'
  516. else if (val <= 0) return '无货'
  517. else if (val > STOCK_ORDER_START && val <= STOCK_ORDER_END) return val
  518. else if (val >= STOCK_ORDER_HAVE_START && val <= STOCK_ORDER_HAVE_END) return '有货'
  519. else if (val > STOCK_ORDER_ALL_NUM) return '充足'
  520. }
  521. },
  522. directives: {
  523. drag: {
  524. bing: function (el) {
  525. console.log(el)
  526. let oDiv = el
  527. oDiv.onmousedown = e => {
  528. console.log('onmousedown')
  529. let disX = e.clientX - oDiv.offsetLeft
  530. let disY = e.clientY - oDiv.offSetTop
  531. document.onmousemove = e => {
  532. let left = e.clientX - disX
  533. let top = e.clientY - disY
  534. oDiv.style.left = left + 'px'
  535. oDiv.style.top = top + 'px'
  536. }
  537. document.onmouseup = e => {
  538. document.onmousemove = null
  539. document.onmouseup = null
  540. }
  541. }
  542. }
  543. }
  544. },
  545. data() {
  546. return {
  547. mainForm: {
  548. orderNum: '',
  549. date: '',
  550. // type: '',
  551. jxsNum: '',
  552. jxsName: '',
  553. fileNum: '',
  554. remark: '',
  555. salesMan: ''
  556. },
  557. mainFormRules: {
  558. // date: [
  559. // { required: true, message: '请选择单据日期', trigger: 'change' }
  560. // ],
  561. // type: [
  562. // { required: true, message: '请选择品类', trigger: 'change' }
  563. // ],
  564. },
  565. goodsList: [],
  566. warehouseList: [],
  567. warehouseValue: '',
  568. isShowDialog: false,
  569. screenForm: {
  570. type: '',
  571. salesType: '',
  572. proNum: '',
  573. proName: '',
  574. proModel: '',
  575. price1: '',
  576. price2: '',
  577. fileNum: ''
  578. },
  579. currentPage: 1,
  580. listTotal: 0,
  581. salesTypeList: [],
  582. typeList: [],
  583. stockList: [],
  584. leftGoodsList: [],
  585. rightGoodsList: [],
  586. leftSelection: [],
  587. rightSelection: [],
  588. isFirst: false,
  589. salesmanList: []
  590. }
  591. },
  592. computed: {
  593. isDealer() {
  594. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  595. },
  596. outSalesmanList() {
  597. let list = []
  598. if (this.goodsList && this.goodsList.length) {
  599. this.goodsList.forEach(item => {
  600. if (item.serviceId) {
  601. let hasItem = findElem(list, 'adminUserId', item.serviceId)
  602. if (hasItem < 0) {
  603. let obj = this.salesmanList.find(o => o.adminUserId == item.serviceId)
  604. if (obj) {
  605. list.push(obj)
  606. }
  607. }
  608. }
  609. })
  610. if (this.isFirst) {
  611. this.isFirst = false
  612. } else {
  613. this.mainForm.salesMan = this.goodsList[0].serviceId
  614. }
  615. }
  616. return list
  617. }
  618. },
  619. watch: {
  620. goodsList: {
  621. handler(newValue, oldValue) {
  622. if (this.goodsList && this.goodsList.length) {
  623. if (this.isFirst) {
  624. this.isFirst = false
  625. } else {
  626. // this.mainForm.salesMan = this.goodsList[0].serviceId;
  627. }
  628. } else {
  629. this.mainForm.salesMan = ''
  630. }
  631. if (newValue && newValue.length) {
  632. newValue.forEach((item, index) => {
  633. this.goodsList[index].compute_amount = item.price * item.qty
  634. this.goodsList[index].compute_flAmount =
  635. ((item.price - item.discAmount) * item.qty * (item.rebateRate * 100)) / 100
  636. this.goodsList[index].compute_zkAmount = item.qty * item.discAmount
  637. this.goodsList[index].compute_sfAmount =
  638. (item.price * item.qty * 100 -
  639. (((item.price - item.discAmount) * item.qty * (item.rebateRate * 100)) / 100) * 100 -
  640. ((item.qty * (item.discAmount * 100)) / 100) * 100) /
  641. 100
  642. })
  643. }
  644. },
  645. immediate: true,
  646. deep: true
  647. }
  648. },
  649. beforeCreate() {
  650. that = this
  651. },
  652. async created() {
  653. await this.getSalesmanList()
  654. this.getDictList()
  655. this.getWarehouseList()
  656. this.getSalesTypeList()
  657. if (this.listItem) {
  658. this.isFirst = true
  659. this.getDetail()
  660. } else {
  661. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  662. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  663. }
  664. },
  665. methods: {
  666. // 返回列表
  667. goBack() {
  668. this.$emit('backListFormDetail')
  669. },
  670. // 获取详情
  671. getDetail() {
  672. getDetail({ id: this.listItem.id }).then(res => {
  673. let data = res.data
  674. this.mainForm.orderNum = data.id
  675. this.mainForm.date = data.theTime.slice(0, 10)
  676. this.mainForm.salesMan = data.k3ServiceId
  677. this.mainForm.jxsNum = data.customerNumber
  678. this.mainForm.jxsName = data.customerName
  679. this.mainForm.fileNum = data.fileNo
  680. this.mainForm.remark = data.remark
  681. data.retailOrderItemList.forEach(item => {
  682. item.status1 = ''
  683. item.status2 = ''
  684. item.rebateAmount = item.curRebateAmount
  685. item.sums1 = ['qty', 'directTransferQty']
  686. item.sums2 = [
  687. 'price',
  688. 'rebateAmount',
  689. 'compute_amount',
  690. 'compute_flAmount',
  691. 'compute_zkAmount',
  692. 'compute_sfAmount'
  693. ]
  694. })
  695. this.goodsList = data.retailOrderItemList
  696. })
  697. },
  698. // 获取仓库列表
  699. getWarehouseList() {
  700. getWarehouseList({
  701. pageNum: 1,
  702. pageSize: -1
  703. }).then(res => {
  704. this.warehouseList = res.data.records
  705. })
  706. },
  707. // 获取销售类型列表
  708. getSalesTypeList() {
  709. getSalesTypeList({
  710. pageNum: 1,
  711. pageSize: -1
  712. }).then(res => {
  713. this.salesTypeList = res.data.records
  714. })
  715. },
  716. getDictList() {
  717. // getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  718. // this.typeList = res.data;
  719. // })
  720. getDictList({ sysDictEnum: 'STOCK_ORDER' }).then(res => {
  721. this.stockList = res.data
  722. })
  723. },
  724. async getSalesmanList() {
  725. const res = await getSalesmanList({
  726. pageNum: 1,
  727. pageSize: -1,
  728. isCustomer: 0,
  729. status: true
  730. })
  731. this.salesmanList = res.data.records
  732. },
  733. // 获取商品列表
  734. getGoodsList() {
  735. getGoodsList({
  736. pageNum: this.currentPage,
  737. pageSize: 10,
  738. // mainId: this.mainForm.type,
  739. saleId: this.screenForm.salesType,
  740. materialCode: this.screenForm.proNum,
  741. materialName: this.screenForm.proName,
  742. specification: this.screenForm.proModel,
  743. price1: this.screenForm.price1,
  744. price2: this.screenForm.price2,
  745. customerId: this.listItem ? this.listItem.customerId : ''
  746. }).then(res => {
  747. let oldGoodsList = this.goodsList
  748. let newGoodsList = res.data.records
  749. for (let i = 0; i < oldGoodsList.length; i++) {
  750. let oldItem = oldGoodsList[i]
  751. for (let j = 0; j < newGoodsList.length; j++) {
  752. let newItem = newGoodsList[j]
  753. if (newItem.id === oldItem.id) {
  754. newGoodsList[j].selected = true
  755. break
  756. }
  757. }
  758. }
  759. res.data.records.forEach(item => {
  760. item.materialName = item.name
  761. item.materialCode = item.number
  762. item.saleTypeName = item.saleName
  763. item.unit = item.baseUnit
  764. item.price = item.batchPrice
  765. item.tax = item.taxRate
  766. item.isDirectTransfer = false
  767. item.directTransferQty = ''
  768. item.status1 = ''
  769. item.status2 = ''
  770. item.rebateAmount = ''
  771. item.rebateRate = ''
  772. item.productPriceId = item.id
  773. item.customerWalletId = item.wallets && item.wallets.length ? item.wallets[0].customerWalletId : ''
  774. item.serviceId = item.wallets && item.wallets.length ? item.wallets[0].serviceId : ''
  775. item.serviceName = item.wallets && item.wallets.length ? item.wallets[0].serviceName : ''
  776. item.needDeleteId = true
  777. item.sums1 = ['qty', 'directTransferQty']
  778. item.sums2 = [
  779. 'price',
  780. 'rebateAmount',
  781. 'compute_amount',
  782. 'compute_flAmount',
  783. 'compute_zkAmount',
  784. 'compute_sfAmount'
  785. ]
  786. })
  787. this.leftGoodsList = res.data.records
  788. this.listTotal = res.data.total
  789. })
  790. },
  791. // 查询重复值并禁选
  792. checkboxSelect(row, rowIndex) {
  793. if (row.selected) {
  794. return false // 禁用
  795. } else {
  796. return true // 不禁用
  797. }
  798. },
  799. // 点击 选择商品
  800. openDialog() {
  801. this.isShowDialog = true
  802. // if(this.mainForm.type) {
  803. this.getGoodsList()
  804. // }
  805. },
  806. // 提交筛选表单
  807. submitScreenForm() {
  808. // if(!this.mainForm.type) {
  809. // return this.$errorMsg('请选择产品大类');
  810. // }
  811. this.currentPage = 1
  812. this.getGoodsList()
  813. },
  814. // 重置筛选表单
  815. resetScreenForm() {
  816. this.$refs.screenForm.resetFields()
  817. this.currentPage = 1
  818. this.getGoodsList()
  819. },
  820. // 更改列表当前页
  821. handleTableCurrentChange(val) {
  822. this.currentPage = val
  823. this.getGoodsList()
  824. },
  825. // 关闭 弹窗
  826. closeDialog() {
  827. this.isShowDialog = false
  828. },
  829. // 左侧列表选择
  830. leftSelectionChange(val) {
  831. this.leftSelection = val
  832. },
  833. // 右侧列表选择
  834. rightSelectionChange(val) {
  835. this.rightSelection = val
  836. },
  837. // 数组去重
  838. delRepeat(arr1, arr2) {
  839. let allArr = arr1.concat(arr2) // 两个数组对象合并
  840. let newArr = [] // 存放去重后数据的新数组
  841. for (let i = 0; i < allArr.length; i++) {
  842. // 循环allArr数组对象的内容
  843. let flag = true // 建立标记,判断数据是否重复,true为不重复
  844. for (let j = 0; j < newArr.length; j++) {
  845. // 循环新数组的内容
  846. if (allArr[i].id == newArr[j].id) {
  847. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  848. flag = false
  849. }
  850. }
  851. if (flag) {
  852. // 判断是否重复
  853. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  854. }
  855. }
  856. return newArr
  857. },
  858. // 全部添加
  859. addAllGoods() {
  860. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  861. },
  862. // 添加
  863. addGoods() {
  864. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  865. },
  866. // 删除
  867. deleteGoods() {
  868. let rightGoodsList = this.rightGoodsList
  869. let rightSelection = this.rightSelection
  870. for (let i = 0; i < rightGoodsList.length; i++) {
  871. for (let j = 0; j < rightSelection.length; j++) {
  872. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  873. this.rightGoodsList.splice(i, 1)
  874. }
  875. }
  876. }
  877. },
  878. // 全部删除
  879. deleteAllGoods() {
  880. this.rightGoodsList = []
  881. },
  882. // 确定 添加产品
  883. submitAddGoods() {
  884. this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList)
  885. this.isShowDialog = false
  886. this.leftGoodsList = []
  887. this.rightGoodsList = []
  888. },
  889. // 删除产品
  890. deleteItem(index) {
  891. this.goodsList.splice(index, 1)
  892. },
  893. // 修改返利钱包
  894. changeWallet(index) {
  895. if (this.goodsList[index].customerWalletId2) {
  896. let obj = this.goodsList[index].rebateWallets.find(
  897. o => o.customerWalletId == this.goodsList[index].customerWalletId2
  898. )
  899. this.goodsList[index].rebateRate = obj.rebateRate
  900. this.goodsList[index].rebateAmount = obj.amount
  901. } else {
  902. this.goodsList[index].rebateRate = ''
  903. this.goodsList[index].rebateAmount = ''
  904. }
  905. },
  906. changeSaleType(index) {
  907. if (this.goodsList[index].saleTypeId) {
  908. let obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId)
  909. this.goodsList[index].saleTypeName = obj.saleName
  910. this.goodsList[index].saleTypeCode = obj.saleCode
  911. } else {
  912. this.goodsList[index].saleTypeName = ''
  913. this.goodsList[index].saleTypeCode = ''
  914. }
  915. },
  916. // 检查库存
  917. checkStock() {
  918. if (!this.warehouseValue) {
  919. return this.$errorMsg('请选择仓库')
  920. }
  921. if (!this.goodsList) {
  922. return this.$errorMsg('请添加货品')
  923. }
  924. let ids = []
  925. this.goodsList.forEach(item => {
  926. ids.push(item.materialId)
  927. })
  928. checkStock({
  929. correspondId: this.warehouseValue,
  930. materialId: ids.join(',')
  931. }).then(res => {
  932. if (res.data) {
  933. this.goodsList.forEach((item, index) => {
  934. item.status1 = res.data[index].allStockNum
  935. item.status2 = res.data[index].stockNum
  936. })
  937. }
  938. })
  939. },
  940. status2Filter(item) {
  941. console.log(item.refundableQty, 'uiui', item.status2)
  942. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查'
  943. if (item.status2 <= 0) {
  944. return '无货'
  945. } else if (item.status2 >= 1 && item.status2 <= 30) {
  946. return item.status2
  947. } else if (item.status2 >= 31 && item.status2 <= 1000) {
  948. return '有货'
  949. } else {
  950. return '充足'
  951. }
  952. // else if (item.status2 <= 0) return '无货';
  953. // else if (item.status2 >= item.qty) return '可用';
  954. // else return '短缺';
  955. },
  956. // 保存
  957. clickSubmitForm() {
  958. this.$refs.mainForm.validate(valid => {
  959. if (valid) {
  960. for (let i = 0; i < this.goodsList.length; i++) {
  961. if (!this.goodsList[i].customerWalletId) {
  962. this.$errorMsg('请选择现金钱包')
  963. return
  964. }
  965. if (!this.goodsList[i].qty) {
  966. this.$errorMsg('请输入数量')
  967. return
  968. }
  969. }
  970. let goodsList = JSON.parse(JSON.stringify(this.goodsList))
  971. goodsList.forEach(item => {
  972. delete item.rebateWallets
  973. delete item.wallets
  974. if (item.needDeleteId) {
  975. delete item.id
  976. }
  977. })
  978. let saleManItem = this.mainForm.salesMan
  979. ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan)
  980. : ''
  981. let params = {
  982. // theTime: this.mainForm.date + ' 00:00:00',
  983. // mainId: this.mainForm.type,
  984. // mainName,
  985. k3ServiceId: this.mainForm.salesMan,
  986. k3ServiceName: saleManItem.nickName || '',
  987. fileNo: this.mainForm.fileNum,
  988. remark: this.mainForm.remark,
  989. type: 1, // 1:普通零售单,2:政策零售单
  990. retailOrderItemList: goodsList
  991. }
  992. if (this.listItem) {
  993. params.id = this.listItem.id
  994. editData(params).then(res => {
  995. this.$successMsg('编辑成功')
  996. this.goBack()
  997. this.$parent.getList()
  998. })
  999. } else {
  1000. addData(params).then(res => {
  1001. this.$successMsg('添加成功')
  1002. this.goBack()
  1003. this.$parent.getList()
  1004. })
  1005. }
  1006. }
  1007. })
  1008. }
  1009. }
  1010. }
  1011. </script>
  1012. <style scoped lang="scss">
  1013. .detail-container {
  1014. width: 100%;
  1015. height: 100%;
  1016. }
  1017. .main-title {
  1018. display: flex;
  1019. justify-content: space-between;
  1020. align-items: center;
  1021. margin-top: 20px;
  1022. height: 60px;
  1023. border-bottom: 1px solid #dcdfe6;
  1024. margin-bottom: 20px;
  1025. .title {
  1026. font-size: 16px;
  1027. font-weight: 600;
  1028. padding-left: 10px;
  1029. }
  1030. }
  1031. .tables {
  1032. display: flex;
  1033. margin-top: 10px;
  1034. .table {
  1035. width: 45%;
  1036. }
  1037. .buttons {
  1038. display: flex;
  1039. flex-direction: column;
  1040. justify-content: center;
  1041. align-items: center;
  1042. padding: 0 10px;
  1043. button {
  1044. margin: 0;
  1045. margin-top: 10px;
  1046. }
  1047. }
  1048. }
  1049. </style>