fix:coding#425

This commit is contained in:
shijing 2024-07-31 16:44:27 +08:00
parent 17b81345a6
commit f7e875b43e
2 changed files with 199 additions and 129 deletions

View File

@ -122,7 +122,15 @@ export default {
obj.state = item.state; obj.state = item.state;
obj.start = item.start_date; obj.start = item.start_date;
obj.start_date = item.start_date; obj.start_date = item.start_date;
obj.duration = 1; let oneDay = 24 * 60 * 60 * 1000; //
let firstDate = new Date(item.start_date);
let secondDate = new Date(item.end_date);
let timeDiff = Math.abs(
secondDate.getTime() - firstDate.getTime()
);
let daysDiff = Math.ceil(timeDiff / oneDay);
console.log("daysDiff", daysDiff + 1);
obj.duration = daysDiff + 1;
obj.progress = item.count_real / item.count; obj.progress = item.count_real / item.count;
obj.count = item.count; obj.count = item.count;
obj.count_ok = item.count_ok; obj.count_ok = item.count_ok;

View File

@ -1,132 +1,194 @@
<template> <template>
<el-drawer v-model="visible" title="任务详情" :size="800" destroy-on-close @closed="$emit('closed')"> <el-drawer
<el-container> v-model="visible"
<el-header> title="任务详情"
<div class="left-panel"> :size="900"
<el-date-picker placeholder="工作日期" v-model="paramsObj.start_date" type="date" value-format="YYYY-MM-DD" destroy-on-close
@change="handleMtaskQuery" /> @closed="$emit('closed')"
</div> >
</el-header> <el-container>
<el-main> <el-header>
<scTable ref="drawer_table" :apiObj="apiObj" row-key="id" stripe :params="paramsObj"> <div class="left-panel">
<el-table-column type="index" width="50" /> <el-date-picker
<el-table-column label="工段" prop="mgroup_name" show-overflow-tooltip> placeholder="工作日期"
</el-table-column> v-model="paramsObj.start_date"
<el-table-column label="任务编号" prop="number"> </el-table-column> type="date"
<el-table-column label="数量" prop="count"> </el-table-column> value-format="YYYY-MM-DD"
<el-table-column label="工作日期" prop="start_date"> @change="handleMtaskQuery"
</el-table-column> />
<el-table-column label="状态" prop="state" show-overflow-tooltip> </div>
<template #default="scope"> </el-header>
<el-tag v-if="scope.row.state !== 40"> <el-main>
{{ state_[scope.row.state] }} <scTable
</el-tag> ref="drawer_table"
<el-tag v-else type="success"> :apiObj="apiObj"
{{ state_[scope.row.state] }} row-key="id"
</el-tag> stripe
</template> :params="paramsObj"
</el-table-column> >
<el-table-column label="操作" fixed="right" width="60"> <el-table-column type="index" width="50" />
<template #default="scope"> <el-table-column
<el-button link label="工段"
type="primary" prop="mgroup_name"
v-auth="'mtask.update'" show-overflow-tooltip
v-if="scope.row.state==10" >
@click="table_edit(scope.row)" >编辑 </el-table-column>
</el-button> <el-table-column label="任务编号" prop="number">
<el-button link type="info" v-else disabled>编辑 </el-table-column>
</el-button> <el-table-column label="数量" prop="count">
</template> </el-table-column>
</el-table-column> <el-table-column
</scTable> label="工作日期"
</el-main> prop="start_date"
</el-container> width="180"
</el-drawer> >
<el-dialog title="编辑任务" v-model="dialogVisible"> <template #default="scope">
<el-form :model="form" ref="dialogForm"> <span
<el-row> v-if="
<el-col :md="12" :sm="24"> scope.row.start_date == scope.row.end_date
<el-form-item label="任务编号:" width="100"> "
{{form.number}} >{{ scope.row.start_date }}</span
</el-form-item> >
</el-col> <span v-else
<el-col :md="12" :sm="24"> >{{ scope.row.start_date }}
<el-form-item label="工段:" width="100"> {{ scope.row.end_date }}</span
{{form.mgroup_name}} >
</el-form-item> </template>
</el-col> </el-table-column>
<el-col :md="12" :sm="24"> <!-- <el-table-column label="工作日期" prop="start_date">
<el-form-item label="工作日期:" width="100"> </el-table-column>
{{form.start_date}} <el-table-column label="工作日期" prop="end_date">
</el-form-item> </el-table-column> -->
</el-col> <el-table-column
<el-col :md="12" :sm="24"> label="状态"
<el-form-item label="数量:" width="100"> prop="state"
<el-input-number v-model="form.count" controls-position="right" :min="0" :step="1" show-overflow-tooltip
:step-strictly="true" style="width: 100%" placeholder="请输入数量"> >
</el-input-number> <template #default="scope">
</el-form-item> <el-tag v-if="scope.row.state !== 40">
</el-col> {{ state_[scope.row.state] }}
</el-row> </el-tag>
</el-form> <el-tag v-else type="success">
<el-footer> {{ state_[scope.row.state] }}
<el-button type="primary" @click="updateMtaskSubmit">确定</el-button> </el-tag>
<el-button @click="dialogVisible = false">取消</el-button> </template>
</el-footer> </el-table-column>
</el-dialog> <el-table-column label="操作" fixed="right" width="60">
<template #default="scope">
<el-button
link
type="primary"
v-auth="'mtask.update'"
v-if="scope.row.state == 10"
@click="table_edit(scope.row)"
>编辑
</el-button>
<el-button link type="info" v-else disabled
>编辑
</el-button>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
</el-drawer>
<el-dialog title="编辑任务" v-model="dialogVisible">
<el-form :model="form" ref="dialogForm">
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="任务编号:" width="100">
{{ form.number }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="工段:" width="100">
{{ form.mgroup_name }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="工作日期:" width="100">
{{ form.start_date }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="数量:" width="100">
<el-input-number
v-model="form.count"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="请输入数量"
>
</el-input-number>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-footer>
<el-button type="primary" @click="updateMtaskSubmit"
>确定</el-button
>
<el-button @click="dialogVisible = false">取消</el-button>
</el-footer>
</el-dialog>
</template> </template>
<script> <script>
export default { export default {
emits: ["closed"], emits: ["closed"],
props: { props: {
utaskId: { type: String, default: '' }, utaskId: { type: String, default: "" },
}, },
data() { data() {
return { return {
visible: false, visible: false,
apiObj: null, apiObj: null,
paramsObj: {}, paramsObj: {},
form:{}, form: {},
state_: { state_: {
10: "创建中", 10: "创建中",
14: "已分解", 14: "已分解",
20: "已下达", 20: "已下达",
30: "生产中", 30: "生产中",
40: "已提交", 40: "已提交",
}, },
isSaveing:false, isSaveing: false,
dialogVisible:false, dialogVisible: false,
} };
}, },
mounted() { mounted() {},
}, methods: {
methods: { handleMtaskQuery() {
handleMtaskQuery() { this.$refs.drawer_table.queryData(this.paramsObj);
this.$refs.drawer_table.queryData(this.paramsObj) },
}, open() {
open() { this.visible = true;
this.visible = true; this.paramsObj.utask = this.utaskId;
this.paramsObj.utask = this.utaskId; this.apiObj = this.$API.pm.mtask.list;
this.apiObj = this.$API.pm.mtask.list; return this;
return this; },
}, table_edit(row) {
table_edit(row){ this.form = Object.assign(row, this.form);
this.form = Object.assign(row,this.form) this.dialogVisible = true;
this.dialogVisible = true; },
}, updateMtaskSubmit() {
updateMtaskSubmit(){ this.$refs.dialogForm.validate(async (valid) => {
this.$refs.dialogForm.validate(async (valid) => { if (valid) {
if (valid) { this.isSaveing = true;
this.isSaveing = true; this.$API.pm.mtask.update
this.$API.pm.mtask.update.req(this.form.id,this.form).then(res=>{ .req(this.form.id, this.form)
this.isSaveing = false; .then((res) => {
this.dialogVisible = false; this.isSaveing = false;
}).catch(err=>{ this.dialogVisible = false;
this.isSaveing = false; })
}) .catch((err) => {
}else{} this.isSaveing = false;
}) });
}, } else {
} }
} });
</script> },
},
};
</script>