apply_form.vue 20 KB

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