安全生产上报

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({ return request({
url: '/api/admin/task/report-submit', url: '/api/admin/task/report-submit',
method: 'post', method: 'post',

@ -19,29 +19,22 @@
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns" <el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width"> :label="column.title" :width="column.width">
<template slot-scope="scope"> <template slot-scope="scope">
<div v-if="column.type == 'img'"> <div v-for="safe in scope.row.safety_task_departments" v-if="safe.departments.id==department_user_id">
<img v-for="(file, vIndex) in getFilePath( scope.row[column.field], column)" :key="vIndex" <div v-if="column.type=='status'">
@click="viewImg(scope.row, column, file.path)" class="table-img" :src="file.path" /> <div v-for="item in isStatus" v-if="safe.status==item.id">
</div> {{item.name}}
<div v-else-if="column.type=='format'"> </div>
<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>
<div v-if="column.field=='task_departments'"> <div v-else-if="column.type=='opt'">
<el-tag v-for="(tag, tIndex) in scope.row['safety_task_departments']" <Button v-if="safe.status==0" ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-right: 5px;margin-bottom: 5px;"> style="margin-left: 10px;">新增上报</Button>
{{tag.departments.name}} <Button v-if="safe.status==1" ghost size="small" @click="edit(safe,true)" type="primary"
</el-tag> 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>
<div v-else>{{scope.row[column.field]}}</div>
</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> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -52,6 +45,57 @@
</div> </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>
</div> </div>
</template> </template>
@ -64,11 +108,16 @@
import Tinymce from '@/components/Tinymce' import Tinymce from '@/components/Tinymce'
import { import {
save, save,
store, submitsave,
del,
get, get,
listdept
} from "../../api/daily/deptindex.js";
import {
listtask listtask
} from "../../api/daily/index.js"; } from "../../api/daily/index.js";
import {
getInfo
} from "../../api/user.js";
export default { export default {
components: { components: {
@ -77,46 +126,34 @@
}, },
data() { data() {
return { return {
isReportSave:false,
checkAll: false, checkAll: false,
isIndeterminate: true, isIndeterminate: true,
department_user_id:"",
paginations: { paginations: {
page: 1, page: 1,
page_size: 15, page_size: 15,
total: 0 total: 0
}, },
show_self: 1,
tableHeight: 0, tableHeight: 0,
dialogFormVisible: false, dialogFormVisible: false,
dialogShowViewVisible:false,
formLabelWidth: "120px", formLabelWidth: "120px",
clientHeight: 0, clientHeight: 0,
form: { form: {
title: "",
content: "", content: "",
file_list: "", file_list: "",
start_date: "",
end_date: "",
department_list: [],
daterange: null
}, },
fileList: [], fileList: [],
tableData: [], tableData: [],
rules: { rules: {
title: [{ content: [{
required: true,
message: '请输入标题',
trigger: 'blur'
}],
department_list: [{
required: true, required: true,
message: '请选择科室', message: '请输入内容',
trigger: 'blur'
}],
daterange: [{
required: true,
message: '请选择日期区间',
trigger: 'blur' trigger: 'blur'
}] }]
}, },
indexUrl: "/api/admin/task/index",
tableHeight: 900, tableHeight: 900,
searchFields: { searchFields: {
KeyWord: "" KeyWord: ""
@ -140,11 +177,10 @@
width: 160, width: 160,
align: "center" align: "center"
}, },
{ {
field: "task_departments_report", field: "status",
title: "上报状态", title: "上报状态",
type: "format", type: "status",
width: 180, width: 180,
align: "center" align: "center"
}, },
@ -158,7 +194,20 @@
uploadOther: { uploadOther: {
token: "" token: ""
}, },
deptOptions: [] deptOptions: [],
isStatus: [{
id: 0,
name: "未上报",
opt: "上报"
}, {
id: 1,
name: "已保存",
opt: "编辑上报"
}, {
id: 2,
name: "已上报",
opt: "查看"
}]
} }
}, },
created() { created() {
@ -168,20 +217,6 @@
}, },
methods: { 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() { initLoad() {
var that = this; var that = this;
var clientHeight = document.documentElement.clientHeight var clientHeight = document.documentElement.clientHeight
@ -196,49 +231,38 @@
this.load(); 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({ listtask({
page: this.paginations.page, page: this.paginations.page,
page_size: this.paginations.page_size, page_size: this.paginations.page_size,
show_self: 1 show_self: this.show_self
}).then(response => { }).then(response => {
this.tableData = response.data; this.tableData = response.data;
this.paginations.page_size = response.total; this.paginations.page_size = response.total;
}).catch(error => { }).catch(error => {
console.log(error) console.log(error)
reject(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) { show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110; this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true; this.dialogViewVisible = false;
this.dialogShowViewVisible = true;
this.info(obj); this.info(obj);
}, },
info(obj) { info(obj) {
var that = this; var that = this;
get(obj.id).then(res => { 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; that.form = result;
let _files = []; let _files = [];
for (var mod of result.files) { for (var mod of result.files) {
@ -246,46 +270,47 @@
m.name = mod.original_name; m.name = mod.original_name;
_files.push(m); _files.push(m);
} }
that.form.safety_task_department_id = result.id;
that.form.daterange = [res.start_date, res.end_date]; that.form.safety_task_id = result.safety_task_id;
for (var m of res.safety_task_departments) {
that.form.department_list.push(m.department_id);
}
that.fileList = _files; that.fileList = _files;
console.log(this.form);
}).catch(error => { }).catch(error => {
//reject(error) //reject(error)
}) })
}, },
edit(obj) { edit(obj,isnew) {
this.form = this.$options.data().form; this.form = this.$options.data().form;
this.clientHeight = document.documentElement.clientHeight - 84 - 110; this.clientHeight = document.documentElement.clientHeight - 84 - 110;
if (obj) { if (isnew) {
var that = this; var that = this;
that.form.content="";
that.info(obj); that.info(obj);
} else {} this.isReportSave = true;
} else {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.form.safety_task_id = obj.id;
this.isReportSave = false;
}
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
submitForm(formName) { editSave(obj) {
var that = this;
},
submitForm(formName, status) {
var that = this;
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
that.form.start_date = that.form.daterange[0]; if(status=="2"){
that.form.end_date = that.form.daterange[1]; submitsave(that.form).then(response => {
if (that.form.id) {
that.form.safety_task_id = that.form.id;
save(that.form).then(response => {
//console.log(response) //console.log(response)
this.$Message.success('操作成功'); this.$Message.success('操作成功');
that.load(); that.load();
that.dialogFormVisible = false; that.dialogFormVisible = false;
}).catch(error => { }).catch(error => {
//reject(error) //reject(error)
}) })
} else { }else{
store(that.form).then(response => { save(that.form).then(response => {
//console.log(response) //console.log(response)
this.$Message.success('操作成功'); this.$Message.success('操作成功');
that.load(); that.load();
@ -331,8 +356,11 @@
}, },
resetForm(formName) { resetForm(formName) {
var that = this; var that = this;
that.fileList = [];
this.$refs[formName].resetFields(); this.$refs[formName].resetFields();
that.dialogFormVisible = false; that.dialogFormVisible = false;
that.dialogShowViewVisible = false;
}, },
} }
} }

Loading…
Cancel
Save