retail_form.vue 26 KB

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