fix:返工物料名称标注

This commit is contained in:
shijing 2024-08-01 15:25:58 +08:00
parent ed4cc66303
commit 896cba6bc9
5 changed files with 164 additions and 85 deletions

View File

@ -3,8 +3,18 @@
<div v-if="initloading" class="sc-select-loading">
<el-icon class="is-loading"><el-icon-loading /></el-icon>
</div>
<el-select v-bind="$attrs" :loading="loading" @visible-change="visibleChange" :value-on-clear="null">
<el-option v-for="item in options" :key="item[id]" :label="item[name]" :value="objValueType ? item : item[id]">
<el-select
v-bind="$attrs"
:loading="loading"
@visible-change="visibleChange"
:value-on-clear="null"
>
<el-option
v-for="item in options"
:key="item[id]"
:label="item[name]"
:value="objValueType ? item : item[id]"
>
<slot name="option" :data="item"></slot>
</el-option>
</el-select>
@ -12,67 +22,103 @@
</template>
<script>
export default {
export default {
props: {
apiObj: { type: Object, default: () => {} },
objValueType: { type: Boolean, default: false },
params: { type: Object, default: () => ({}) },
id: {type: String, default: 'id'},
name: {type: String, default: 'name'},
showName: {type: String, default: null},
id: { type: String, default: "id" },
name: { type: String, default: "name" },
showName: { type: String, default: null },
},
data() {
return {
loading: false,
options: [],
initloading: false
}
initloading: false,
};
},
created() {
//options
if(this.hasValue()){
this.initloading = true
this.getRemoteData()
if (this.hasValue()) {
this.initloading = true;
this.getRemoteData();
}
},
methods: {
//
visibleChange(ispoen){
if(ispoen && this.options.length==0 && this.apiObj){
this.getRemoteData()
visibleChange(ispoen) {
if (ispoen && this.options.length == 0 && this.apiObj) {
this.getRemoteData();
}
},
//
async getRemoteData(){
this.loading = true
var query = Object.assign({page:0}, this.params)
var res = await this.apiObj.req(query)
this.loading = false
this.initloading = false
if (this.$attrs.modelValue !== null && !res.some(option => option[this.id] === this.$attrs.modelValue)) {
this.options = [{ [this.id]: this.$attrs.modelValue, [this.name]: this.showName }, ...res];
}else{
this.options = res
async getRemoteData() {
this.loading = true;
var query = Object.assign({ page: 0 }, this.params);
var res = await this.apiObj.req(query);
this.loading = false;
this.initloading = false;
if (
this.$attrs.modelValue !== null &&
!res.some(
(option) => option[this.id] === this.$attrs.modelValue
)
) {
this.options = [
{
[this.id]: this.$attrs.modelValue,
[this.name]: this.showName,
},
...res,
];
} else {
this.options = res;
}
},
//
hasValue(){
if(Array.isArray(this.$attrs.modelValue) && this.$attrs.modelValue.length <= 0){
return false
}else if(this.$attrs.modelValue){
return true
}else{
return false
}
}
}
hasValue() {
if (
Array.isArray(this.$attrs.modelValue) &&
this.$attrs.modelValue.length <= 0
) {
return false;
} else if (this.$attrs.modelValue) {
return true;
} else {
return false;
}
},
},
};
</script>
<style scoped>
.sc-select {display: inline-block;position: relative;min-width: 120px;}
.sc-select-loading {position: absolute;top:0;left:0;right:0;bottom:0;background: #fff;z-index: 100;border-radius: 5px;border: 1px solid #EBEEF5;display: flex;align-items: center;padding-left:10px;}
.sc-select-loading i {font-size: 14px;}
.sc-select {
display: inline-block;
position: relative;
min-width: 120px;
}
.sc-select-loading {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #fff;
z-index: 100;
border-radius: 5px;
border: 1px solid #ebeef5;
display: flex;
align-items: center;
padding-left: 10px;
}
.sc-select-loading i {
font-size: 14px;
}
.dark .sc-select-loading {background: var(--el-bg-color-overlay);border-color: var(--el-border-color-light);}
.dark .sc-select-loading {
background: var(--el-bg-color-overlay);
border-color: var(--el-border-color-light);
}
</style>

View File

@ -13,14 +13,14 @@
type="primary"
icon="el-icon-plus"
@click="table_add(10)"
v-auth="'mgroup.create'"
v-auth="'mllog.create'"
>新增</el-button
>
<el-button
type="primary"
icon="el-icon-plus"
@click="table_add(20)"
v-auth="'mgroup.create'"
v-auth="'mlog.submit'"
>返工</el-button
>
</div>
@ -76,9 +76,9 @@
<el-table-column label="数量" prop="count"></el-table-column>
<el-table-column label="类型" prop="type">
<template #default="scope">
<el-tag v-if="scope.row.type == 10">交送</el-tag>
<el-tag v-if="scope.row.type == 20" type="success"
>接收</el-tag
<el-tag v-if="scope.row.type == 10">正常</el-tag>
<el-tag v-if="scope.row.type == 20" type="danger"
>返工</el-tag
>
</template>
</el-table-column>
@ -125,7 +125,7 @@
link
size="small"
@click="table_edit(scope.row)"
v-auth="'mgroup.update'"
v-auth="'mlog.update'"
type="primary"
v-if="
scope.row.send_mgroup == mgroupId &&
@ -145,7 +145,7 @@
<el-button
link
size="small"
v-auth="'mgroup.delete'"
v-auth="'mlog.delete'"
type="danger"
>删除</el-button
>

View File

@ -42,8 +42,15 @@
<el-table-column
label="物料名称"
prop="material_name"
min-width="120"
></el-table-column>
min-width="150"
>
<template #default="scope">
{{ scope.row.material_name }}
<span v-if="scope.row.material_origin != null"
>{{ scope.row.material_origin_name }}</span
>
</template>
</el-table-column>
<el-table-column
label="批次号"
prop="batch"

View File

@ -112,7 +112,6 @@
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
:disabledDate="disabledDateFn"
/>
</el-form-item>
</el-col>
@ -130,7 +129,13 @@
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="操作人">
<el-select
<ehsSelect
v-model="form.handle_user"
:showName="form.handle_user_name"
:apiObj="this.$API.system.user.list"
:params="{ depts: dept }"
></ehsSelect>
<!-- <el-select
v-model="form.handle_user"
placeholder="操作人"
clearable
@ -142,7 +147,7 @@
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-select> -->
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">

View File

@ -6,7 +6,7 @@
type="primary"
icon="el-icon-plus"
@click="table_add"
v-auth="'mgroup.create'"
v-auth="'mlog.create'"
>新增</el-button
>
</div>
@ -82,7 +82,7 @@
label="操作"
fixed="right"
align="center"
width="180"
width="150"
>
<template #default="scope">
<el-button
@ -94,10 +94,6 @@
@click.stop="table_edit(scope.row)"
>编辑</el-button
>
<el-divider
direction="vertical"
v-if="scope.row.submit_time == null"
></el-divider>
<el-button
link
size="small"
@ -105,16 +101,23 @@
type="primary"
>详情</el-button
>
<el-divider direction="vertical"></el-divider>
<el-button
link
size="small"
v-auth="'mgroup.delete'"
v-auth="'mlog.delete'"
type="danger"
v-if="scope.row.submit_time == null"
@click.stop="table_del(scope.row, scope.$index)"
>删除</el-button
>
<!-- <el-button
link
v-else
size="small"
type="danger"
@click.stop="mlogRevert(scope.row)"
>撤回</el-button
> -->
</template>
</el-table-column>
</scTable>
@ -178,7 +181,7 @@ export default {
that.$API.mtm.mgroup.list
.req({ page: 0, search: that.mgroupName })
.then((res) => {
if(res.length != 1){
if (res.length != 1) {
that.$message.error("获取工段错误");
return;
}
@ -191,20 +194,21 @@ export default {
});
},
methods: {
//
//
table_add() {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
});
},
//
//
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("edit").setData(row);
});
},
//
table_detail(row) {
this.mlogId = row.id;
this.dialog.detail = true;
@ -212,7 +216,7 @@ export default {
this.$refs.detailDialog.open();
});
},
//
//
table_del(row) {
this.$confirm(`确定删除吗?`, "提示", {
type: "warning",
@ -228,6 +232,23 @@ export default {
});
});
},
//
mlogRevert(row) {
this.$confirm(`确定撤回该日志吗?`, "提示", {
type: "warning",
}).then(() => {
var id = row.id;
this.$API.wpm.mlog.revert.req(id).then((res) => {
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
this.$refs.table.refresh();
this.$message.success("撤回成功");
}
});
});
},
//
selectionChange(selection) {
this.selection = selection;