apply_form.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. <div style="font-size: 12px; color: #333; margin-bottom: 20px;">注:发货申请时,库存数量为实时数量,请选择完成选择后及时保存提交,否则数量可能有变,被其他商家开单而导致库存不足。</div>
  8. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="90px" size="small" label-position="right">
  9. <el-row :gutter="20">
  10. <el-col :xs="24" :sm="12" :lg="8">
  11. <el-form-item label="订单号" prop="orderNum">
  12. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  16. <el-form-item label="单据日期" prop="date">
  17. <el-date-picker
  18. v-model="mainForm.date"
  19. disabled
  20. type="date"
  21. value-format="yyyy-MM-dd"
  22. style="width: 100%;"
  23. placeholder="系统自动生成">
  24. </el-date-picker>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :xs="24" :sm="12" :lg="8">
  28. <el-form-item label="制单人" prop="createMan">
  29. <el-input v-model="mainForm.createMan" disabled></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :xs="24" :sm="12" :lg="8">
  33. <el-form-item label="经销商编号" prop="jxsNum">
  34. <el-input v-model="mainForm.jxsNum" disabled></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :xs="24" :sm="12" :lg="16">
  38. <el-form-item label="经销商名称" prop="jxsName">
  39. <el-input v-model="mainForm.jxsName" disabled></el-input>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :xs="24" :sm="24" :lg="24">
  43. <el-form-item label="备注" prop="headerRemark">
  44. <el-input v-model="mainForm.headerRemark" placeholder="请输入备注"></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :xs="24" :sm="8" :lg="8">
  48. <el-form-item label="附件" prop="fileUrl">
  49. <fileUpload :fileList="fileList" />
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. </el-form>
  54. <div class="main-title">
  55. <div class="title">货品信息</div>
  56. <div>
  57. <!-- <span style="font-size: 14px; margin-right: 10px">仓库</span>
  58. <el-select v-model="screenForm.warehouse" placeholder="请选择发货仓库" size="small" filterable clearable :disabled="goodsList.length > 0">
  59. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  60. </el-select>
  61. <el-divider direction="vertical"></el-divider> -->
  62. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加引用</el-button>
  63. </div>
  64. </div>
  65. <div class="table" style="margin-top: 20px">
  66. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  67. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  68. <el-table-column align="center" label="引用单号" prop="mainOrderId" min-width="180" show-overflow-tooltip></el-table-column>
  69. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  70. <el-table-column align="center" label="物料编码" prop="materialCode" min-width="120" show-overflow-tooltip></el-table-column>
  71. <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
  72. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  73. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  74. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  75. <el-table-column align="center" label="数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
  76. <el-table-column align="center" label="申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
  77. <template slot-scope="scope">
  78. <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
  79. </template>
  80. </el-table-column>
  81. <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
  82. <el-table-column align="center" label="未申请数量" prop="canApply" min-width="100" show-overflow-tooltip> </el-table-column>
  83. <el-table-column align="left" label="表头备注" prop="headerRemark" min-width="160" show-overflow-tooltip>
  84. <template slot-scope="scope">
  85. <el-input v-model="scope.row.headerRemark" size="small" :disabled="isDealer"></el-input>
  86. </template>
  87. </el-table-column>
  88. <el-table-column align="left" label="表体备注" prop="invoiceRemark" min-width="160" show-overflow-tooltip>
  89. <template slot-scope="scope">
  90. <el-input v-model="scope.row.invoiceRemark" size="small" :disabled="isDealer"></el-input>
  91. </template>
  92. </el-table-column>
  93. <el-table-column align="center" label="操作" width="100" fixed="right">
  94. <template slot-scope="scope">
  95. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. </div>
  100. <div class="page-footer">
  101. <div class="footer">
  102. <!-- <el-button type="primary" @click="clickSubmitForm('SAVE')">保 存</el-button> -->
  103. <el-button type="primary" @click="clickSubmitForm('WAIT')">提交审核</el-button>
  104. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  105. <el-button slot="reference">关 闭</el-button>
  106. </el-popconfirm>
  107. </div>
  108. </div>
  109. <el-dialog title="添加引用" :visible.sync="isShowDialog" width="80%">
  110. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left" label-width="70px">
  111. <el-row :gutter="20">
  112. <el-col :xs="12" :sm="6" :lg="6">
  113. <el-form-item prop="warehouse" label="选择仓库">
  114. <el-select v-model="screenForm.warehouse" placeholder="请选择仓库" size="small" filterable clearable :disabled="goodsList.length > 0" style="width: 100%">
  115. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  116. </el-select>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :xs="12" :sm="6" :lg="6">
  120. <el-form-item prop="type" label="存货类别">
  121. <el-select v-model="screenForm.type" placeholder="选择存货类别" style="width: 100%" clearable :disabled="goodsList.length > 0">
  122. <el-option v-for="item in categoryList" :key="item.name" :label="item.name" :value="item.name"></el-option>
  123. </el-select>
  124. </el-form-item>
  125. </el-col>
  126. <!-- <el-col :xs="12" :sm="6" :lg="6">
  127. <el-form-item prop="type" label="产品大类">
  128. <el-select v-model="screenForm.type" placeholder="选择产品大类" style="width: 100%" :disabled="goodsList.length > 0 || tableSelection.length > 0">
  129. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  130. </el-select>
  131. </el-form-item>
  132. </el-col> -->
  133. <el-col :xs="12" :sm="6" :lg="6">
  134. <el-form-item prop="orderNum" label="订单号">
  135. <el-input v-model="screenForm.orderNum" placeholder="请输入订单号"></el-input>
  136. </el-form-item>
  137. </el-col>
  138. <el-col :xs="12" :sm="6" :lg="6">
  139. <el-form-item label="规格型号" prop="model">
  140. <el-input v-model="screenForm.model" placeholder="请输入规格型号"></el-input>
  141. </el-form-item>
  142. </el-col>
  143. <el-col :xs="24" :sm="24" :lg="24" class="tr">
  144. <el-form-item label="">
  145. <el-button size="small" @click="resetScreenForm">清空</el-button>
  146. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. </el-form>
  151. <div class="table">
  152. <el-table :data="tableGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400">
  153. <el-table-column align="center" label="订单号" prop="mainOrderId" min-width="140" show-overflow-tooltip></el-table-column>
  154. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  155. <el-table-column align="center" label="存货类别" prop="categoryName" min-width="100" show-overflow-tooltip></el-table-column>
  156. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  157. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  158. <el-table-column align="center" label="单位" prop="unit" min-width="80" show-overflow-tooltip></el-table-column>
  159. <el-table-column align="center" label="数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
  160. <el-table-column align="center" label="未申请数量" prop="canApply" min-width="100" show-overflow-tooltip></el-table-column>
  161. <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
  162. <el-table-column align="center" label="本次申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
  163. <template slot-scope="scope">
  164. <el-input v-model="scope.row.invoiceNum" size="small" type="number" :disabled="scope.row.selected"></el-input>
  165. </template>
  166. </el-table-column>
  167. <el-table-column align="center" label="对应库存数量" prop="stockCorrespond" min-width="110" show-overflow-tooltip>
  168. <template slot-scope="scope">
  169. {{stockFilter(scope.row, 2)}}
  170. </template>
  171. </el-table-column>
  172. <el-table-column align="center" label="已申请未出货数量" prop="sendQty" min-width="100" show-overflow-tooltip></el-table-column>
  173. <!-- <el-table-column align="center" label="总库存数量" prop="stockAdequate" min-width="100" show-overflow-tooltip>
  174. <template slot-scope="scope">
  175. {{stockFilter(scope.row, 1)}}
  176. </template>
  177. </el-table-column> -->
  178. </el-table>
  179. <div class="pagination clearfix" style="margin-top: 10px">
  180. <div class="fr">
  181. <el-pagination
  182. @current-change="handleTableCurrentChange"
  183. :current-page="currentPage"
  184. :page-size="10"
  185. background
  186. layout="prev, pager, next"
  187. :total="listTotal">
  188. </el-pagination>
  189. </div>
  190. </div>
  191. </div>
  192. <span slot="footer" class="dialog-footer">
  193. <el-button @click="closeDialog">取 消</el-button>
  194. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  195. </span>
  196. </el-dialog>
  197. </div>
  198. </template>
  199. <script>
  200. import { getApplyDetail, addApply, editApply, getGoodsList, getWarehouseList, getDealerList } from "@/api/supply/apply";
  201. import { getDictList, getCategoryList } from '@/api/common'
  202. import { findElem } from '@/utils/util'
  203. import fileUpload from '@/components/Common/file-upload.vue'
  204. export default {
  205. components: {
  206. fileUpload
  207. },
  208. name: 'ApplyForm',
  209. componentName: 'ApplyForm',
  210. props: ['listItem'],
  211. data() {
  212. return {
  213. mainForm: {
  214. orderNum: '',
  215. date: '',
  216. jxsNum: '',
  217. jxsName: '',
  218. headerRemark: '',
  219. createMan: '',
  220. },
  221. mainFormRules: {
  222. // date: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  223. },
  224. dealerList: [],
  225. fileList: [],
  226. goodsList: [],
  227. warehouseList: [],
  228. isShowDialog: false,
  229. screenForm: {
  230. warehouse: '',
  231. type: '',
  232. orderNum: '',
  233. model: '',
  234. },
  235. currentPage: 1,
  236. listTotal: 0,
  237. // typeList: [],
  238. stockList: [],
  239. categoryList: [],
  240. tableGoodsList: [],
  241. }
  242. },
  243. computed: {
  244. isDealer() {
  245. return JSON.parse(localStorage.getItem("supply_user")).isCustomer
  246. },
  247. },
  248. created() {
  249. this.getDictList();
  250. this.getWarehouseList();
  251. this.getDealerList();
  252. this.getCategoryList();
  253. if(this.listItem) {
  254. this.getDetail();
  255. }else {
  256. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  257. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  258. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  259. }
  260. },
  261. methods: {
  262. // 返回列表
  263. goBack() {
  264. this.$emit('backListFormDetail');
  265. },
  266. // 获取详情
  267. getDetail() {
  268. getApplyDetail({id: this.listItem.id}).then(res => {
  269. let data = res.data;
  270. this.mainForm.orderNum = data.id;
  271. this.mainForm.date = data.orderTime;
  272. this.mainForm.jxsNum = data.customerNumber;
  273. this.mainForm.jxsName = data.customerName;
  274. this.mainForm.createMan = data.createBy;
  275. this.mainForm.headerRemark = data.headerRemark;
  276. this.mainForm.remark = data.remark;
  277. this.screenForm.warehouse = data.correspondId;
  278. this.fileList = data.fileUrl ? [{
  279. url: data.fileUrl,
  280. name: data.fileName
  281. }] : [];
  282. // data.orders.forEach(item => {
  283. // item.orderId = item.id;
  284. // })
  285. this.goodsList = data.orders;
  286. // this.screenForm.type = data.mainId;
  287. })
  288. },
  289. // 获取仓库列表
  290. getWarehouseList() {
  291. getWarehouseList({
  292. pageNum: 1,
  293. pageSize: -1
  294. }).then((res) => {
  295. this.warehouseList = res.data.records;
  296. })
  297. },
  298. getDictList() {
  299. getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
  300. this.stockList = res.data;
  301. })
  302. },
  303. // 获取经销商列表
  304. getDealerList() {
  305. getDealerList({
  306. pageNum: 1,
  307. pageSize: -1,
  308. bindUser: false
  309. }).then(res => {
  310. this.dealerList = res.data.records;
  311. })
  312. },
  313. // 获取存货类别列表
  314. getCategoryList() {
  315. getCategoryList({
  316. pageNum: 1,
  317. pageSize: -1,
  318. }).then(res => {
  319. this.categoryList = res.data.records;
  320. })
  321. },
  322. // 库存字段
  323. stockFilter(item, type) {
  324. let STOCK_ORDER_INVOICE = this.stockList.find(o => o.dictCode == 'STOCK_ORDER_INVOICE').dictValue;
  325. if(type === 1) {
  326. return item.stockAdequate > STOCK_ORDER_INVOICE ? '充足' : item.stockAdequate;
  327. }
  328. if(type === 2) {
  329. if ( item.stockCorrespond <= 0 ) {
  330. return '无货'
  331. }else if(item.stockCorrespond >= 1 && item.stockCorrespond <= 30){
  332. return item.stockCorrespond
  333. }else if(item.stockCorrespond >=31 && item.stockCorrespond <= 1000 ){
  334. return '有货'
  335. }else{
  336. return '充足'
  337. }
  338. // return item.stockCorrespond > STOCK_ORDER_INVOICE ? '充足' : item.stockCorrespond;
  339. }
  340. },
  341. // 获取商品列表
  342. getGoodsList() {
  343. getGoodsList({
  344. pageNum: this.currentPage,
  345. pageSize: 10,
  346. correspondId: this.screenForm.warehouse,
  347. categoryName: this.screenForm.type,
  348. id: this.screenForm.orderNum,
  349. specification: this.screenForm.model,
  350. }).then(res => {
  351. let oldGoodsList = this.goodsList;
  352. let newGoodsList = res.data.records;
  353. for(let i = 0; i < oldGoodsList.length; i++) {
  354. let oldItem = oldGoodsList[i]
  355. for(let j = 0; j < newGoodsList.length; j++) {
  356. let newItem = newGoodsList[j]
  357. if(newItem.orderId === oldItem.orderId){
  358. newGoodsList[j].selected = true;
  359. newGoodsList[j].invoiceNum = oldGoodsList[i].invoiceNum;
  360. break;
  361. }
  362. }
  363. }
  364. this.tableGoodsList = newGoodsList;
  365. this.listTotal = res.data.total;
  366. })
  367. },
  368. // 查询重复值并禁选
  369. checkboxSelect(row, rowIndex) {
  370. if (row.selected) {
  371. return false // 禁用
  372. }else{
  373. return true // 不禁用
  374. }
  375. },
  376. // 点击 选择商品
  377. openDialog() {
  378. this.isShowDialog = true;
  379. if(this.screenForm.warehouse) {
  380. this.getGoodsList();
  381. }
  382. },
  383. // 提交筛选表单
  384. submitScreenForm() {
  385. if(!this.screenForm.warehouse) {
  386. return this.$errorMsg('请选择仓库');
  387. }
  388. if(!this.screenForm.type) {
  389. return this.$errorMsg('请选择存货类别');
  390. }
  391. this.currentPage = 1;
  392. this.getGoodsList();
  393. },
  394. // 重置筛选表单
  395. resetScreenForm() {
  396. this.$refs.screenForm.resetFields();
  397. this.currentPage = 1;
  398. this.tableGoodsList = [];
  399. // this.getGoodsList();
  400. },
  401. // 更改列表当前页
  402. handleTableCurrentChange(val) {
  403. this.currentPage = val;
  404. this.getGoodsList();
  405. },
  406. // 关闭 弹窗
  407. closeDialog() {
  408. this.isShowDialog = false;
  409. },
  410. // 确定 添加产品
  411. submitAddGoods() {
  412. let tableSelection = [];
  413. this.tableGoodsList.forEach(item => {
  414. if((item.invoiceNum || item.invoiceNum === 0) && !item.selected) {
  415. tableSelection.push(item);
  416. }
  417. });
  418. for(let i=0; i<tableSelection.length; i++) {
  419. if(tableSelection[i].invoiceNum < 1) {
  420. this.$errorMsg('申请数量要大于0');
  421. return;
  422. }
  423. // if(tableSelection[i].invoiceNum > tableSelection[i].canApply) {
  424. // this.$errorMsg('申请数量不能大于未申请数量');
  425. // return;
  426. // }
  427. }
  428. this.isShowDialog = false;
  429. this.tableGoodsList = [];
  430. this.goodsList = this.goodsList.concat(tableSelection);
  431. },
  432. // 删除产品
  433. deleteItem(index) {
  434. this.goodsList.splice(index, 1);
  435. },
  436. // 保存
  437. clickSubmitForm(status) {
  438. this.$refs.mainForm.validate((valid) => {
  439. if (valid) {
  440. if(this.goodsList.length < 1) {
  441. return this.$errorMsg('请添加引用');
  442. }
  443. for(let i=0; i<this.goodsList.length; i++) {
  444. if(!this.goodsList[i].invoiceNum) {
  445. this.$errorMsg('请输入申请数量');
  446. return;
  447. }
  448. // if(this.goodsList[i].invoiceNum > this.goodsList[i].canApply) {
  449. // this.$errorMsg('申请数量不能大于未申请数量');
  450. // return;
  451. // }
  452. }
  453. if(!this.screenForm.warehouse) {
  454. return this.$errorMsg('请选择仓库');
  455. }
  456. let correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name;
  457. let params = {
  458. id: this.listItem ? this.listItem.id : '',
  459. headerRemark: this.mainForm.headerRemark,
  460. remark:this.mainForm.headerRemark,
  461. fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
  462. fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
  463. // orderType: 1, // 1零售单 2家用工程 3商用工程
  464. correspondId: this.screenForm.warehouse,
  465. correspondName,
  466. orders: this.goodsList,
  467. examineStatus: status,
  468. }
  469. if(this.listItem) {
  470. editApply(params).then(res => {
  471. this.$successMsg('编辑成功');
  472. this.goBack();
  473. this.$parent.getList();
  474. })
  475. }else {
  476. addApply(params).then(res => {
  477. this.$successMsg('添加成功');
  478. this.goBack();
  479. this.$parent.getList();
  480. })
  481. }
  482. }
  483. })
  484. },
  485. }
  486. }
  487. </script>
  488. <style scoped lang="scss">
  489. .detail-container {
  490. width: 100%;
  491. height: 100%;
  492. }
  493. .main-title {
  494. display: flex;
  495. justify-content: space-between;
  496. align-items: center;
  497. margin-top: 20px;
  498. height: 60px;
  499. border-bottom: 1px solid #DCDFE6;
  500. margin-bottom: 20px;
  501. .title {
  502. font-size: 16px;
  503. font-weight: 600;
  504. padding-left: 10px;
  505. }
  506. }
  507. </style>