retail_form.vue 31 KB

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