安全生产上报

master
Lion 4 years ago
parent 037395df99
commit d1a1cc28fc

@ -25,7 +25,7 @@ export function get(safety_task_department_id) {
})
}
export function submit(data) {
export function submitsave(data) {
return request({
url: '/api/admin/task/report-submit',
method: 'post',

@ -18,30 +18,23 @@
<el-table-column type="index" width="50" align="center"> </el-table-column>
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width">
<template slot-scope="scope">
<div v-if="column.type == 'img'">
<img v-for="(file, vIndex) in getFilePath( scope.row[column.field], column)" :key="vIndex"
@click="viewImg(scope.row, column, file.path)" class="table-img" :src="file.path" />
<template slot-scope="scope">
<div v-for="safe in scope.row.safety_task_departments" v-if="safe.departments.id==department_user_id">
<div v-if="column.type=='status'">
<div v-for="item in isStatus" v-if="safe.status==item.id">
{{item.name}}
</div>
</div>
<div v-else-if="column.type=='opt'">
<Button v-if="safe.status==0" ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">新增上报</Button>
<Button v-if="safe.status==1" ghost size="small" @click="edit(safe,true)" type="primary"
style="margin-left: 10px;">编辑上报</Button>
<Button v-if="safe.status==2" ghost size="small" @click="show(safe)" type="primary"
style="margin-left: 10px;">查看上报</Button>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</div>
<div v-else-if="column.type=='format'">
<div v-if="column.field=='task_departments_report'">
<el-link type="primary">
{{scope.row["safety_task_departments_count"]+"/"+scope.row["safety_task_departments_report_count"]}}
</el-link>
</div>
<div v-if="column.field=='task_departments'">
<el-tag v-for="(tag, tIndex) in scope.row['safety_task_departments']"
style="margin-right: 5px;margin-bottom: 5px;">
{{tag.departments.name}}
</el-tag>
</div>
</div>
<div v-else-if="column.type=='opt'">
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">上报</Button>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
</el-table-column>
</el-table>
@ -50,7 +43,58 @@
:page-size="paginations.page_size" background layout="prev, pager, next" :total="paginations.total">
</el-pagination>
</div>
</div>
</div>
<el-dialog title="安全生产任务上报编辑" :visible.sync="dialogFormVisible" fullscreen width="90%">
<div class="dialogConcent" :style="{height:clientHeight+'px'}">
<el-scrollbar style="flex: 1">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-form-item label="内容" prop="content">
<div style="width: 99.9%;">
<tinymce v-model="form.content" :height="300" />
</div>
</el-form-item>
<el-form-item label="附件" prop="file_list">
<el-upload class="upload-demo" :on-success="handlesuccess" :data="uploadOther"
action="/api/admin/upload-file" :on-remove="handleRemove" :before-remove="beforeRemove"
:on-exceed="handleExceed" :file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
</el-form>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer" v-if="!isReportSave">
<el-button @click="resetForm('form')"> </el-button>
<el-button type="primary" v-preventReClick @click="submitForm('form','1')"> </el-button>
</div>
<div slot="footer" class="dialog-footer" v-if="isReportSave">
<el-button @click="resetForm('form')"> </el-button>
<el-button type="primary" v-preventReClick @click="submitForm('form','1')"> </el-button>
<el-button type="primary" v-preventReClick @click="submitForm('form', '2')"> </el-button>
</div>
</el-dialog>
<el-dialog title="安全生产任务上报内容查看" :visible.sync="dialogShowViewVisible" fullscreen>
<div class="dialogConcent" :style="{height:clientHeight+'px'}">
<el-scrollbar style="flex: 1">
<el-form :model="form" ref="form" label-position="right" :label-width="formLabelWidth">
<el-form-item label="内容" prop="content">
<div style="width: 99.9%;" v-html="form.content">
</div>
</el-form-item>
<el-form-item label="附件" prop="files">
<el-link v-for="item in form.files" target="_blank" :href="item.url" type="primary">{{item.original_name}}</el-link>
</el-form-item>
</el-form>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')"> </el-button>
</div>
</el-dialog>
</div>
</div>
@ -64,11 +108,16 @@
import Tinymce from '@/components/Tinymce'
import {
save,
store,
del,
submitsave,
get,
listdept
} from "../../api/daily/deptindex.js";
import {
listtask
} from "../../api/daily/index.js";
} from "../../api/daily/index.js";
import {
getInfo
} from "../../api/user.js";
export default {
components: {
@ -76,47 +125,35 @@
Tinymce
},
data() {
return {
return {
isReportSave:false,
checkAll: false,
isIndeterminate: true,
isIndeterminate: true,
department_user_id:"",
paginations: {
page: 1,
page_size: 15,
total: 0
},
show_self: 1,
tableHeight: 0,
dialogFormVisible: false,
dialogFormVisible: false,
dialogShowViewVisible:false,
formLabelWidth: "120px",
clientHeight: 0,
form: {
title: "",
content: "",
file_list: "",
start_date: "",
end_date: "",
department_list: [],
daterange: null
},
fileList: [],
tableData: [],
rules: {
title: [{
required: true,
message: '请输入标题',
trigger: 'blur'
}],
department_list: [{
content: [{
required: true,
message: '请选择科室',
trigger: 'blur'
}],
daterange: [{
required: true,
message: '请选择日期区间',
message: '请输入内容',
trigger: 'blur'
}]
},
indexUrl: "/api/admin/task/index",
tableHeight: 900,
searchFields: {
KeyWord: ""
@ -140,11 +177,10 @@
width: 160,
align: "center"
},
{
field: "task_departments_report",
field: "status",
title: "上报状态",
type: "format",
type: "status",
width: 180,
align: "center"
},
@ -158,7 +194,20 @@
uploadOther: {
token: ""
},
deptOptions: []
deptOptions: [],
isStatus: [{
id: 0,
name: "未上报",
opt: "上报"
}, {
id: 1,
name: "已保存",
opt: "编辑上报"
}, {
id: 2,
name: "已上报",
opt: "查看"
}]
}
},
created() {
@ -168,20 +217,6 @@
},
methods: {
handleCheckAllChange(val) {
console.log(val)
let options = [];
for (var m of this.deptOptions) {
options.push(m.id);
}
this.form.department_list = val ? options : [];
this.isIndeterminate = false;
},
handleCheckedDeptChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.deptOptions.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.deptOptions.length;
},
initLoad() {
var that = this;
var clientHeight = document.documentElement.clientHeight
@ -195,104 +230,94 @@
this.paginations.page = page;
this.load();
},
load() {
load() {
getInfo({
// token:this.uploadOther.token;
}).then(response => {
this.department_user_id = response.department_id
}).catch(error => {
console.log(error)
reject(error)
});
listtask({
page: this.paginations.page,
page_size: this.paginations.page_size,
show_self: 1
show_self: this.show_self
}).then(response => {
this.tableData = response.data;
this.paginations.page_size = response.total;
}).catch(error => {
console.log(error)
reject(error)
})
});
},
del(obj) {
var that = this;
if (obj) {
this.$Modal.confirm({
title: '确认要删除数据?',
onOk: () => {
del(obj.id).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true;
this.dialogViewVisible = false;
this.dialogShowViewVisible = true;
this.info(obj);
},
info(obj) {
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
let result = Object.assign(that.form, res);
// this.$set(that.form,res);
that.form = result;
let _files = [];
for (var mod of result.files) {
let m = Object.assign({}, mod);
m.name = mod.original_name;
_files.push(m);
}
that.form.daterange = [res.start_date, res.end_date];
for (var m of res.safety_task_departments) {
that.form.department_list.push(m.department_id);
}
that.fileList = _files;
}
that.form.safety_task_department_id = result.id;
that.form.safety_task_id = result.safety_task_id;
that.fileList = _files;
console.log(this.form);
}).catch(error => {
//reject(error)
})
},
edit(obj) {
edit(obj,isnew) {
this.form = this.$options.data().form;
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
if (obj) {
var that = this;
that.info(obj);
} else {}
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
if (isnew) {
var that = this;
that.form.content="";
that.info(obj);
this.isReportSave = true;
} else {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.form.safety_task_id = obj.id;
this.isReportSave = false;
}
this.dialogFormVisible = true;
},
editSave(obj) {
},
submitForm(formName) {
submitForm(formName, status) {
var that = this;
this.$refs[formName].validate((valid) => {
if (valid) {
that.form.start_date = that.form.daterange[0];
that.form.end_date = that.form.daterange[1];
if (that.form.id) {
that.form.safety_task_id = that.form.id;
save(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
} else {
store(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
if (valid) {
if(status=="2"){
submitsave(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
}else{
save(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
}
that.fileList = [];
} else {
@ -330,9 +355,12 @@
this.form.file_list = listUrl;
},
resetForm(formName) {
var that = this;
var that = this;
that.fileList = [];
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
that.dialogFormVisible = false;
that.dialogShowViewVisible = false;
},
}
}

Loading…
Cancel
Save