retail_form.vue 31 KB

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