apply_form.vue 21 KB

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