<template>
|
<el-dialog
|
title="煤种"
|
:close-on-click-modal="false"
|
append-to-body
|
width="60%"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
ref="dataForm"
|
@keyup.enter.native="dataFormSubmitHandle()"
|
>
|
<el-row>
|
<el-col>
|
<el-form-item>
|
<el-table
|
:data="dataList"
|
border
|
style="width: 100%">
|
<el-table-column
|
type="index"
|
align="center"
|
min-width="50"
|
label="序号">
|
</el-table-column>
|
<el-table-column
|
prop=""
|
label="煤种"
|
min-width="120"
|
align="center">
|
<template slot-scope="scope">
|
<dict-select-tag style="width: 100%"
|
v-model="scope.row.mz"
|
placeholder="煤种"
|
:dictCode="dictCodeMz"
|
:clearable="true"/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop=""
|
label="比例"
|
align="center"
|
min-width="100">
|
<template slot-scope="scope">
|
<el-input-number
|
v-model="scope.row.proportion"
|
:min="1"
|
label="比例"
|
></el-input-number>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop=""
|
label="操作"
|
min-width="100"
|
align="center">
|
<template slot-scope="scope">
|
<el-button
|
@click.native.prevent="addExpressionRow(scope.$index, dataList)"
|
type="text"
|
size="small">
|
添加
|
</el-button>
|
<el-button
|
@click.native.prevent="deleteExpressionRow(scope.$index, dataList)"
|
type="text"
|
size="small">
|
删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
<el-button :loading="loading" @click="visible = false">取消</el-button>
|
<el-button :loading="loading" type="primary" @click="dataFormSubmit()">确定</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import debounce from "lodash/debounce";
|
import DictSelectTag from "@/components/dict/dict-select-tag";
|
|
export default {
|
components: { DictSelectTag },
|
data() {
|
return {
|
visible: false,
|
loading: false,
|
dataForm: {
|
mc:''
|
},
|
dictCodeMz:'',
|
dataList:[{
|
mz: " ",
|
proportion: " ",
|
}]
|
};
|
},
|
methods: {
|
init(mc,mclx) {
|
this.visible = true;
|
this.$nextTick(() => {
|
this.$refs["dataForm"].resetFields();
|
this.dataForm.mc = mc;
|
this.dataList=[{
|
mc: this.dataForm.mc,
|
mz: "",
|
proportion: "",
|
}];
|
if ("ymc" === mclx) {
|
this.dictCodeMz = "ymmz";
|
} else if ("cpc" === mclx) {
|
this.dictCodeMz = "cpmz";
|
}
|
this.getList();
|
});
|
},
|
// 获取信息
|
getList() {
|
this.$http
|
.get(
|
`/iailab-iems-coal-proddisp/warehouse/mcmz/list/${this.dataForm.mc}`
|
)
|
.then(({ data: res }) => {
|
if (res.code !== 0) {
|
return this.$message.error(res.msg);
|
}
|
if(res.data!=null){
|
this.dataList = res.data
|
}
|
})
|
.catch(() => {});
|
},
|
// 表单提交
|
dataFormSubmit: debounce(
|
function () {
|
this.$refs["dataForm"].validate((valid) => {
|
if (!valid) {
|
return false;
|
}
|
this.loading = true;
|
this.$http.post(
|
"/iailab-iems-coal-proddisp/warehouse/mcmz/add",
|
this.dataList
|
)
|
.then(({ data: res }) => {
|
if (res.code !== 0) {
|
return this.$message.error(res.msg);
|
}
|
this.$message({
|
message: this.$t("prompt.success"),
|
type: "success",
|
duration: 500,
|
onClose: () => {
|
this.visible = false;
|
this.$emit("refreshDataList");
|
},
|
});
|
this.loading = false;
|
})
|
.catch(() => {});
|
});
|
},
|
1000,
|
{ leading: true, trailing: false }
|
),
|
//删除行
|
deleteExpressionRow (index, rows) {
|
if (!rows || rows.length === 1) {
|
this.$message({
|
message: '不能全部删除!',
|
type: 'error',
|
duration: 1500
|
})
|
return
|
}
|
rows.splice(index, 1)
|
},
|
//添加行
|
addExpressionRow (index, rows) {
|
let row = JSON.parse(JSON.stringify(rows[index]))
|
rows.splice(index, 0, row)
|
}
|
},
|
};
|
</script>
|