123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- <template>
- <div class="detail-container">
- <el-page-header @back="goBack" :content="listItem ? '编辑-发货申请':'新增-发货申请'"></el-page-header>
- <div class="main-title">
- <div class="title">发货申请单信息</div>
- </div>
- <div style="font-size: 12px; color: #333; margin-bottom: 20px;">注:发货申请时,库存数量为实时数量,请选择完成选择后及时保存提交,否则数量可能有变,被其他商家开单而导致库存不足。</div>
- <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="90px" size="small" label-position="right">
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="订单号" prop="orderNum">
- <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
- <el-form-item label="单据日期" prop="date">
- <el-date-picker
- v-model="mainForm.date"
- disabled
- type="date"
- value-format="yyyy-MM-dd"
- style="width: 100%;"
- placeholder="系统自动生成">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="制单人" prop="createMan">
- <el-input v-model="mainForm.createMan" disabled></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="经销商编号" prop="jxsNum">
- <el-input v-model="mainForm.jxsNum" disabled></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="16">
- <el-form-item label="经销商名称" prop="jxsName">
- <el-input v-model="mainForm.jxsName" disabled></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="24">
- <el-form-item label="备注" prop="headerRemark">
- <el-input v-model="mainForm.headerRemark" placeholder="请输入备注"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="8" :lg="8">
- <el-form-item label="附件" prop="fileUrl">
- <fileUpload :fileList="fileList" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="main-title">
- <div class="title">货品信息</div>
- <div>
- <!-- <span style="font-size: 14px; margin-right: 10px">仓库</span>
- <el-select v-model="screenForm.warehouse" placeholder="请选择发货仓库" size="small" filterable clearable :disabled="goodsList.length > 0">
- <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
- </el-select>
- <el-divider direction="vertical"></el-divider> -->
- <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加引用</el-button>
- </div>
- </div>
- <div class="table" style="margin-top: 20px">
- <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
- <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
- <el-table-column align="center" label="引用单号" prop="mainOrderId" min-width="180" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="物料编码" prop="materialCode" min-width="120" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="未申请数量" prop="canApply" min-width="100" show-overflow-tooltip> </el-table-column>
- <el-table-column align="left" label="表头备注" prop="headerRemark" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.headerRemark" size="small" :disabled="isDealer"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="left" label="表体备注" prop="invoiceRemark" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.invoiceRemark" size="small" :disabled="isDealer"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作" width="100" fixed="right">
- <template slot-scope="scope">
- <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="page-footer">
- <div class="footer">
- <!-- <el-button type="primary" @click="clickSubmitForm('SAVE')">保 存</el-button> -->
- <el-button type="primary" @click="clickSubmitForm('WAIT')">提交审核</el-button>
- <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
- <el-button slot="reference">返回列表</el-button>
- </el-popconfirm>
- </div>
- </div>
- <el-dialog title="添加引用" :visible.sync="isShowDialog" width="80%">
- <el-form ref="screenForm" :model="screenForm" size="small" label-position="left" label-width="70px">
- <el-row :gutter="20">
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="warehouse" label="选择仓库">
- <el-select v-model="screenForm.warehouse" placeholder="请选择仓库" size="small" filterable clearable :disabled="goodsList.length > 0" style="width: 100%">
- <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="type" label="存货类别">
- <el-select v-model="screenForm.type" placeholder="选择存货类别" style="width: 100%" clearable :disabled="goodsList.length > 0">
- <el-option v-for="item in categoryList" :key="item.name" :label="item.name" :value="item.name"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <!-- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="type" label="产品大类">
- <el-select v-model="screenForm.type" placeholder="选择产品大类" style="width: 100%" :disabled="goodsList.length > 0 || tableSelection.length > 0">
- <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
- </el-select>
- </el-form-item>
- </el-col> -->
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item prop="orderNum" label="订单号">
- <el-input v-model="screenForm.orderNum" placeholder="请输入订单号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="6">
- <el-form-item label="规格型号" prop="model">
- <el-input v-model="screenForm.model" placeholder="请输入规格型号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="24" class="tr">
- <el-form-item label="">
- <el-button size="small" @click="resetScreenForm">清空</el-button>
- <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="table">
- <el-table :data="tableGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400">
- <el-table-column align="center" label="新旧单标识" prop="mainOrderId" min-width="140" show-overflow-tooltip>
- <template slot-scope="scope">
- {{scope.row.orderBase==1?"新单":"旧单"}}
- </template>
- </el-table-column>
- <el-table-column align="center" label="订单号" prop="mainOrderId" min-width="140" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="存货类别" prop="categoryName" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="单位" prop="unit" min-width="80" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="未申请数量" prop="canApply" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="本次申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.invoiceNum" size="small" type="number" @mousewheel.native.prevent :disabled="scope.row.selected"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="对应库存数量" prop="stockCorrespond" min-width="110" show-overflow-tooltip>
- <template slot-scope="scope">
- {{stockFilter(scope.row, 2)}}
- </template>
- </el-table-column>
- <el-table-column align="center" label="已申请未出货数量" prop="sendQty" min-width="100" show-overflow-tooltip></el-table-column>
- <!-- <el-table-column align="center" label="总库存数量" prop="stockAdequate" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- {{stockFilter(scope.row, 1)}}
- </template>
- </el-table-column> -->
- </el-table>
- <div class="pagination clearfix" style="margin-top: 10px">
- <div class="fr">
- <el-pagination
- @current-change="handleTableCurrentChange"
- :current-page="currentPage"
- :page-size="10"
- background
- layout="prev, pager, next"
- :total="listTotal">
- </el-pagination>
- </div>
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeDialog">取 消</el-button>
- <el-button type="primary" @click="submitAddGoods">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getApplyDetail, addApply, editApply, getGoodsList, getWarehouseList, getDealerList } from "@/api/supply/apply";
- import { getDictList, getCategoryList } from '@/api/common'
- import { findElem } from '@/utils/util'
- import fileUpload from '@/components/Common/file-upload.vue'
- export default {
- components: {
- fileUpload
- },
- name: 'ApplyForm',
- componentName: 'ApplyForm',
- props: ['listItem'],
- data() {
- return {
- mainForm: {
- orderNum: '',
- date: '',
- jxsNum: '',
- jxsName: '',
- headerRemark: '',
- createMan: '',
- },
- mainFormRules: {
- // date: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
- },
- dealerList: [],
- fileList: [],
- goodsList: [],
- warehouseList: [],
- isShowDialog: false,
- screenForm: {
- warehouse: '',
- type: '',
- orderNum: '',
- model: '',
- },
- currentPage: 1,
- listTotal: 0,
- // typeList: [],
- stockList: [],
- categoryList: [],
- tableGoodsList: [],
- }
- },
- computed: {
- isDealer() {
- return JSON.parse(localStorage.getItem("supply_user")).isCustomer
- },
- },
- created() {
- this.getDictList();
- this.getWarehouseList();
- this.getDealerList();
- this.getCategoryList();
- if(this.listItem) {
- this.getDetail();
- }else {
- this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
- this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
- this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
- }
- },
- methods: {
- // 返回列表
- goBack() {
- this.$emit('backListFormDetail');
- },
- // 获取详情
- getDetail() {
- getApplyDetail({id: this.listItem.id}).then(res => {
- let data = res.data;
- this.mainForm.orderNum = data.id;
- this.mainForm.date = data.orderTime;
- this.mainForm.jxsNum = data.customerNumber;
- this.mainForm.jxsName = data.customerName;
- this.mainForm.createMan = data.createBy;
- this.mainForm.headerRemark = data.headerRemark;
- this.mainForm.remark = data.remark;
- this.screenForm.warehouse = data.correspondId;
- this.fileList = data.fileUrl ? [{
- url: data.fileUrl,
- name: data.fileName
- }] : [];
- // data.orders.forEach(item => {
- // item.orderId = item.id;
- // })
- this.goodsList = data.orders;
- // this.screenForm.type = data.mainId;
- })
- },
- // 获取仓库列表
- getWarehouseList() {
- getWarehouseList({
- pageNum: 1,
- pageSize: -1
- }).then((res) => {
- this.warehouseList = res.data.records;
- })
- },
- getDictList() {
- getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
- this.stockList = res.data;
- })
- },
- // 获取经销商列表
- getDealerList() {
- getDealerList({
- pageNum: 1,
- pageSize: -1,
- bindUser: false
- }).then(res => {
- this.dealerList = res.data.records;
- })
- },
- // 获取存货类别列表
- getCategoryList() {
- getCategoryList({
- pageNum: 1,
- pageSize: -1,
- }).then(res => {
- this.categoryList = res.data.records;
- })
- },
- // 库存字段
- stockFilter(item, type) {
- let STOCK_ORDER_INVOICE = this.stockList.find(o => o.dictCode == 'STOCK_ORDER_INVOICE').dictValue;
- if(type === 1) {
- return item.stockAdequate > STOCK_ORDER_INVOICE ? '充足' : item.stockAdequate;
- }
- if(type === 2) {
- if ( item.stockCorrespond <= 0 ) {
- return '无货'
- }else if(item.stockCorrespond >= 1 && item.stockCorrespond <= 30){
- return item.stockCorrespond
- }else if(item.stockCorrespond >=31 && item.stockCorrespond <= 1000 ){
- return '有货'
- }else{
- return '充足'
- }
- // return item.stockCorrespond > STOCK_ORDER_INVOICE ? '充足' : item.stockCorrespond;
- }
- },
- // 获取商品列表
- getGoodsList() {
- getGoodsList({
- pageNum: this.currentPage,
- pageSize: 10,
- correspondId: this.screenForm.warehouse,
- categoryName: this.screenForm.type,
- id: this.screenForm.orderNum,
- specification: this.screenForm.model,
- }).then(res => {
- let oldGoodsList = this.goodsList;
- let newGoodsList = res.data.records;
- for(let i = 0; i < oldGoodsList.length; i++) {
- let oldItem = oldGoodsList[i]
- for(let j = 0; j < newGoodsList.length; j++) {
- let newItem = newGoodsList[j]
- if(newItem.orderId === oldItem.orderId){
- newGoodsList[j].selected = true;
- newGoodsList[j].invoiceNum = oldGoodsList[i].invoiceNum;
- break;
- }
- }
- }
- this.tableGoodsList = newGoodsList;
- this.listTotal = res.data.total;
- })
- },
- // 查询重复值并禁选
- checkboxSelect(row, rowIndex) {
- if (row.selected) {
- return false // 禁用
- }else{
- return true // 不禁用
- }
- },
- // 点击 选择商品
- openDialog() {
- this.isShowDialog = true;
- if(this.screenForm.warehouse) {
- this.getGoodsList();
- }
- },
- // 提交筛选表单
- submitScreenForm() {
- if(!this.screenForm.warehouse) {
- return this.$errorMsg('请选择仓库');
- }
- if(!this.screenForm.type) {
- return this.$errorMsg('请选择存货类别');
- }
- this.currentPage = 1;
- this.getGoodsList();
- },
- // 重置筛选表单
- resetScreenForm() {
- this.$refs.screenForm.resetFields();
- this.currentPage = 1;
- this.tableGoodsList = [];
- // this.getGoodsList();
- },
- // 更改列表当前页
- handleTableCurrentChange(val) {
- this.currentPage = val;
- this.getGoodsList();
- },
- // 关闭 弹窗
- closeDialog() {
- this.isShowDialog = false;
- },
- // 确定 添加产品
- submitAddGoods() {
- let tableSelection = [];
- this.tableGoodsList.forEach(item => {
- if((item.invoiceNum || item.invoiceNum === 0) && !item.selected) {
- tableSelection.push(item);
- }
- });
- for(let i=0; i<tableSelection.length; i++) {
- for (let j = i+1; j < tableSelection.length; j++) {
- if (tableSelection[i].orderBase !== tableSelection[j].orderBase) {
- return this.$errorMsg('只能选择新单或旧单');
- }
- }
- if(tableSelection[i].invoiceNum < 1) {
- this.$errorMsg('申请数量要大于0');
- return;
- }
- // if(tableSelection[i].invoiceNum > tableSelection[i].canApply) {
- // this.$errorMsg('申请数量不能大于未申请数量');
- // return;
- // }
- }
- this.isShowDialog = false;
- this.tableGoodsList = [];
- this.goodsList = this.goodsList.concat(tableSelection);
- },
- // 删除产品
- deleteItem(index) {
- this.goodsList.splice(index, 1);
- },
- // 保存
- clickSubmitForm(status) {
- this.$refs.mainForm.validate((valid) => {
- if (valid) {
- if(this.goodsList.length < 1) {
- return this.$errorMsg('请添加引用');
- }
- for(let i=0; i<this.goodsList.length; i++) {
- if(!Number(this.goodsList[i].invoiceNum)) {
- this.$errorMsg('请输入申请数量');
- return;
- }
- // if(this.goodsList[i].invoiceNum > this.goodsList[i].canApply) {
- // this.$errorMsg('申请数量不能大于未申请数量');
- // return;
- // }
- }
- if(!this.screenForm.warehouse) {
- return this.$errorMsg('请选择仓库');
- }
- let correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name;
- let params = {
- id: this.listItem ? this.listItem.id : '',
- headerRemark: this.mainForm.headerRemark,
- remark:this.mainForm.headerRemark,
- fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
- fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
- // orderType: 1, // 1零售单 2家用工程 3商用工程
- correspondId: this.screenForm.warehouse,
- correspondName,
- orders: this.goodsList,
- examineStatus: status,
- }
- if(this.listItem) {
- editApply(params).then(res => {
- this.$successMsg('编辑成功');
- this.goBack();
- this.$parent.getList();
- })
- }else {
- addApply(params).then(res => {
- this.$successMsg('添加成功');
- this.goBack();
- this.$parent.getList();
- })
- }
- }
- })
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .detail-container {
- width: 100%;
- height: 100%;
- }
- .main-title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 20px;
- height: 60px;
- border-bottom: 1px solid #DCDFE6;
- margin-bottom: 20px;
- .title {
- font-size: 16px;
- font-weight: 600;
- padding-left: 10px;
- }
- }
- </style>
|