123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- <template>
- <div class="detail-container">
- <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
- <div class="main-title">
- <div class="title">预留单信息</div>
- </div>
- <el-form ref="mainForm" :model="mainForm" label-width="70px" size="small" label-position="left">
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="6">
- <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="6" style="height: 51px;">
- <el-form-item label="单据日期" prop="orderDate">
- <el-date-picker
- v-model="mainForm.orderDate"
- 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="6">
- <el-form-item label="制单人" prop="createMan">
- <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6" style="height: 51px;">
- <el-form-item label="制单日期" prop="createDate">
- <el-date-picker
- v-model="mainForm.createDate"
- disabled
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- style="width: 100%;"
- placeholder="选择日期">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="24">
- <el-form-item label="备注" prop="remark">
- <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div style="margin-top: 20px">
- <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog" v-if="!listItem">添加引用</el-button>
- <el-button type="danger" size="small" icon="el-icon-minus" @click="deleteGoods" :disabled="tableSelection.length < 1" v-if="!listItem">批量删除</el-button>
- <el-button size="small" icon="el-icon-edit" @click="batchChangeNum" :disabled="tableSelection.length < 1" v-if="!listItem">批量设置预留数量</el-button>
- </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" @selection-change="tableSelectionChange">
- <el-table-column align="center" type="selection" width="55"></el-table-column>
- <el-table-column align="center" label="销售订单号" prop="orderId" min-width="200" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="订单日期" prop="orderTime" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- {{scope.row.orderTime | dateToDayFilter}}
- </template>
- </el-table-column>
- <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- <div v-if="scope.row.orderId || listItem">{{scope.row.customerNumber}}</div>
- <el-select
- v-else
- v-model="scope.row.customerNumber"
- placeholder="选择经销商"
- size="small"
- filterable
- remote
- clearable
- :remote-method="checkDealerList"
- @change="changeDealer(scope.$index)">
- <el-option
- v-for="item in dealerList"
- :key="item.number"
- :label="item.number"
- :value="item.number">
- <span>{{ item.number }}</span>
- <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <div v-if="scope.row.orderId || listItem">{{scope.row.materialCode}}</div>
- <el-select
- v-else
- v-model="scope.row.materialCode"
- placeholder="选择产品"
- size="small"
- filterable
- remote
- clearable
- :remote-method="checkMaterialList"
- @change="changeMaterial(scope.$index)">
- <el-option
- v-for="item in materialList"
- :key="item.number"
- :label="item.number"
- :value="item.number">
- <span>{{ item.number }}</span>
- <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" 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="oldNum" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="预留数量" prop="reservedNum" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input v-model="scope.row.reservedNum" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="center" label="订单数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="可用数量" prop="openNumber" min-width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="预留仓库" prop="correspondId" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-select v-model="scope.row.correspondId" placeholder="选择预留仓库" size="small" clearable @change="changeWarehouse(scope.$index)">
- <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="center" label="备注" prop="reservedRemark" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="状态" prop="status" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- {{scope.row.status ? '执行中':'已关闭'}}
- </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)" v-if="!listItem">删除</el-button>
- <el-button type="text" @click="changeItem(scope.$index, 0)" v-if="listItem && scope.row.status === 1">关闭</el-button>
- <el-button type="text" @click="changeItem(scope.$index, 1)" v-if="listItem && scope.row.status === 0">开启</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="add" v-if="!listItem"><el-button type="text" icon="el-icon-plus" @click="addGoods">添加行</el-button></div>
- </div>
-
- <div class="page-footer">
- <div class="footer">
- <el-button type="primary" @click="clickSubmitForm">保 存</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">
- <el-row :gutter="20">
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="jxsNum">
- <el-input v-model="screenForm.jxsNum" placeholder="经销商编码"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="jxsName">
- <el-input v-model="screenForm.jxsName" placeholder="经销商名称"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="type">
- <el-select v-model="screenForm.type" placeholder="产品大类" style="width: 100%">
- <el-option v-for="item in typeList" :key="item.dictValue" :label="item.dictValue" :value="item.dictValue"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="goodsNum">
- <el-input v-model="screenForm.goodsNum" placeholder="产品编码"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="goodsCode">
- <el-input v-model="screenForm.goodsCode" placeholder="物料代码"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="goodsName">
- <el-input v-model="screenForm.goodsName" placeholder="产品名称"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="model">
- <el-input v-model="screenForm.model" placeholder="规格型号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="orderType">
- <el-select v-model="screenForm.orderType" placeholder="订单类型" style="width: 100%">
- <el-option v-for="item in orderTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="6" :lg="4">
- <el-form-item prop="saleNum">
- <el-input v-model="screenForm.saleNum" placeholder="销售订单号"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="12" :sm="18" :lg="12" 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="dialogGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="dialogSelectionChange">
- <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
- <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="120" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="订单日期" prop="orderTime" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- {{scope.row.orderTime | dateToDayFilter}}
- </template>
- </el-table-column>
- <el-table-column align="center" label="订单类型" prop="orderType" min-width="100" show-overflow-tooltip>
- <template slot-scope="scope">
- {{scope.row.orderType | orderTypeFilter}}
- </template>
- </el-table-column>
- <el-table-column align="center" label="订单号" prop="orderId" 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="160" show-overflow-tooltip></el-table-column>
- <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" 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="100" show-overflow-tooltip></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 { getDetail, getGoodsList, addData, editData, checkDealerList, checkMaterialList, getWarehouseList } from "@/api/supply/reserve";
- import { getDictList } from '@/api/common'
- let that
- export default {
- name: 'ReserveForm',
- componentName: 'ReserveForm',
- props: ['listItem'],
- filters: {
- orderTypeFilter(val) {
- let obj = that.orderTypeFilterList.find(o => o.value == val);
- return obj ? obj.label : ''
- }
- },
- data() {
- return {
- mainForm: {
- orderNum: '',
- orderDate: '',
- createMan: '',
- createDate: '',
- remark: '',
- },
- goodsList: [],
- tableSelection: [],
- typeList: [],
- orderTypeList: [
- { label: '商用工程单', value: 'TRADE' },
- { label: '家用工程单', value: 'HOME' },
- { label: '零售单', value: 'RETAIL' },
- { label: '销售政策单', value: 'RETAIL_POLICY' },
- { label: '置换单', value: 'PERMU' },
- ],
- orderTypeFilterList: [
- { label: '商用工程单', value: 'TRADE' },
- { label: '家用工程单', value: 'HOME' },
- { label: '零售单', value: 'RETAIL' },
- { label: '销售政策单', value: 'RETAIL_POLICY' },
- { label: '置换单', value: 'PERMU_HOME' },
- { label: '置换单', value: 'PERMU_TRADE' },
- { label: '置换单', value: 'PERMU_RETAIL' },
- { label: '置换单', value: 'PERMU_RETAIL_POLICY' },
- ],
- isShowDialog: false,
- screenForm: {
- jxsNum: '',
- jxsName: '',
- type: '',
- goodsNum: '',
- goodsCode: '',
- goodsName: '',
- model: '',
- orderType: '',
- saleNum: '',
- },
- currentPage: 1,
- listTotal: 0,
-
- dialogGoodsList: [],
- dialogSelection: [],
- dealerList: [],
- materialList: [],
- warehouseList: [],
- }
- },
- beforeCreate() {
- that = this;
- },
- async created() {
- await this.getWarehouseList();
- if(this.listItem) {
- this.getDetail();
- }else {
- this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
- this.mainForm.createDate = this.getDate();
- }
- },
- methods: {
- getDate() {
- var date = new Date();
- var seperator1 = "-";
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- var currentdate = year + seperator1 + month + seperator1 + strDate;
- return currentdate;
- },
- getDictList() {
- getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
- this.typeList = res.data;
- })
- },
- // 获取仓库列表
- async getWarehouseList() {
- const res = await getWarehouseList({
- pageNum: 1,
- pageSize: -1,
- });
- this.warehouseList = res.data.records;
- },
- // 返回列表
- goBack() {
- this.$emit('backListFormDetail');
- },
- // 获取详情
- getDetail() {
- getDetail({id: this.listItem.id}).then(res => {
- let data = res.data;
- this.mainForm.orderNum = data.id;
- this.mainForm.orderDate = data.orderTime;
- this.mainForm.createMan = data.createBy;
- this.mainForm.createDate = data.createTime;
- this.mainForm.remark = data.remark;
- this.goodsList = data.reservedOrderItems;
- })
- },
- // 获取商品列表
- getGoodsList() {
- getGoodsList({
- pageNum: this.currentPage,
- pageSize: 10,
- customerNumber: this.screenForm.jxsNum,
- customerName: this.screenForm.jxsName,
- mainName: this.screenForm.type,
- materialCode: this.screenForm.goodsNum,
- materialOldNumber: this.screenForm.goodsCode,
- materialName: this.screenForm.goodsName,
- specification: this.screenForm.model,
- orderType: this.screenForm.orderType,
- orderId: this.screenForm.saleNum,
- }).then(res => {
- res.data.records.forEach(item => {
- item.status = 1;
- item.reservedStatus = 1;
- });
- 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;
- break;
- }
- }
- }
- this.dialogGoodsList = newGoodsList;
- this.listTotal = res.data.total;
- })
- },
- // 查询重复值并禁选
- checkboxSelect(row, rowIndex) {
- if (row.selected) {
- return false // 禁用
- }else{
- return true // 不禁用
- }
- },
- // 点击 选择商品
- openDialog() {
- this.isShowDialog = true;
- this.getDictList();
- this.getGoodsList();
- },
- // 提交筛选表单
- submitScreenForm() {
- this.currentPage = 1;
- this.getGoodsList();
- },
- // 重置筛选表单
- resetScreenForm() {
- this.$refs.screenForm.resetFields();
- this.currentPage = 1;
- this.dialogGoodsList = [];
- this.getGoodsList();
- },
- // 更改列表当前页
- handleTableCurrentChange(val) {
- if(this.dialogSelection.length > 0) {
- return this.$errorMsg('已选择产品不可切换');
- }
- this.currentPage = val;
- this.getGoodsList();
- },
- // 关闭 弹窗
- closeDialog() {
- this.$refs.screenForm.resetFields();
- this.isShowDialog = false;
- },
- // 列表选择
- dialogSelectionChange(val) {
- this.dialogSelection = val;
- },
- // 确定 添加产品
- submitAddGoods() {
- this.goodsList = this.goodsList.concat(this.dialogSelection);
- this.isShowDialog = false;
- this.dialogGoodsList = [];
- },
- // 删除产品
- deleteItem(index) {
- this.goodsList.splice(index, 1);
- },
- // 修改状态
- changeItem(index, status) {
- this.goodsList[index].status = status;
- },
- tableSelectionChange(val) {
- this.tableSelection = val;
- },
- // 批量删除
- deleteGoods() {
- let goodsList = this.goodsList;
- let tableSelection = this.tableSelection;
- for(let i = 0; i < goodsList.length; i++) {
- for(let j = 0; j < tableSelection.length; j++) {
- if(tableSelection[j].orderId == goodsList[i].orderId){
- this.goodsList.splice(i, 1);
- }
- }
- }
- },
- // 批量修改数量
- batchChangeNum() {
- this.$prompt('请输入预留数量', '批量设置', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputValidator: function(value) {
- if(!value) return '请输入预留数量'
- },
- }).then(({ value }) => {
- this.tableSelection.forEach(item => {
- item.reservedNum = value;
- })
- }).catch(() => {});
- },
- // 添加产品
- addGoods() {
- this.goodsList.push({
- reservedStatus: 2,
- status: 1
- })
- },
- // 查询经销商列表
- checkDealerList(query) {
- checkDealerList({
- number: query,
- }).then(res => {
- this.dealerList = res.data || [];
- })
- },
- // 更改经销商
- changeDealer(index) {
- if(this.goodsList[index].customerNumber) {
- let obj = this.dealerList.find(o => o.number == this.goodsList[index].customerNumber);
- this.goodsList[index].customerName = obj.name;
- this.goodsList[index].customerId = obj.id;
- }else {
- this.goodsList[index].customerName = '';
- this.goodsList[index].customerId = '';
- }
- },
- // 查询产品
- checkMaterialList(query) {
- checkMaterialList({
- number: query,
- }).then(res => {
- this.materialList = res.data || [];
- })
- },
- // 更改产品
- changeMaterial(index) {
- if(this.goodsList[index].materialCode) {
- let obj = this.materialList.find(o => o.number == this.goodsList[index].materialCode);
- this.goodsList[index].materialName = obj.name;
- this.goodsList[index].materialId = obj.id;
- this.goodsList[index].materialOldNumber = obj.oldNumber;
- this.goodsList[index].specification = obj.specification;
- this.goodsList[index].unit = obj.baseUnitId;
- }else {
- this.goodsList[index].materialName = '';
- this.goodsList[index].materialId = '';
- this.goodsList[index].materialOldNumber = '';
- this.goodsList[index].specification = '';
- this.goodsList[index].unit = '';
- }
- },
- // 修改仓库
- changeWarehouse(index) {
- if(this.goodsList[index].correspondId) {
- let obj = this.warehouseList.find(o => o.id == this.goodsList[index].correspondId);
- this.goodsList[index].correspondName = obj.name;
- }else {
- this.goodsList[index].correspondName = '';
- }
- },
- // 提交
- clickSubmitForm() {
- this.$refs.mainForm.validate((valid) => {
- if (valid) {
- let params = {
- // orderTime: this.mainForm.orderDate + ' 00:00:00',
- remark: this.mainForm.remark,
- reservedOrderItems: this.goodsList,
- }
- if(this.listItem) {
- params.id = this.listItem.id;
- editData(params).then(res => {
- this.$successMsg('编辑成功');
- this.goBack();
- this.$parent.getList();
- })
- }else {
- addData(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;
- }
- }
- .add {
- display: flex;
- align-items: center;
- justify-content: center;
- border: 1px solid #EBEEF5;
- border-top: none;
- height: 50px;
- }
- </style>
|