retail_form.vue 28 KB

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