This commit is contained in:
caoqianming 2020-07-31 14:49:49 +08:00
commit 54896344ee
8 changed files with 309 additions and 283 deletions

View File

@ -136,11 +136,23 @@ export default {
this.$router.push({path:"/employee/train/update",query:{id:scope.row.id}}) this.$router.push({path:"/employee/train/update",query:{id:scope.row.id}})
}, },
handleDelete(scope) { handleDelete(scope) {
deleteImplementRule(scope.row.id).then(res=>{ this.$confirm('确定删除本条数据吗?', '提示', {
this.$message.success('成功') confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteTrain(scope.row.id).then(res=>{
this.$message.success('删除成功')
this.getList() this.getList()
}) })
} }).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
} }
}; };
</script> </script>

View File

@ -54,14 +54,15 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="选择学员" prop="employees"> <el-form-item label="选择学员" prop="employees">
<el-input v-model="formData.employees" readonly="readonly" clearable :style="{width: '80%'}">
</el-input> <!--<el-lable v-for="(item,index) in type_employees" :key="index">{{item.name}},</el-lable>-->
<el-input v-model="formData.employeeList" placeholder="参加人员" clearable :style="{width: '80%'}"></el-input>
<el-button type="text" @click="dialogVisible = true">选择</el-button> <el-button type="text" @click="dialogVisible = true">选择</el-button>
<el-dialog title="" :visible.sync="dialogVisible"> <el-dialog title="" :visible.sync="dialogVisible">
<Userselet @closeMoule="closeMoule"></Userselet> <Userselet @closeMoule="closeMoule"></Userselet>
</el-dialog> </el-dialog>
<SpeciesAnalyzed @closeMoule="closeMoule"></SpeciesAnalyzed>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -121,14 +122,10 @@
<script> <script>
import { createTrain} from "@/api/train"; import { createTrain} from "@/api/train";
import { getUserList} from "@/api/user";
import { getDictList } from "@/api/dict"; import { getDictList } from "@/api/dict";
import { genTree } from "@/utils"; import { genTree } from "@/utils";
import { getOrgAll } from "@/api/org"
import { getRoleAll } from "@/api/role"
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { upUrl, upHeaders } from "@/api/file";
import Userselet from '@/views/employee/userselet'; import Userselet from '@/views/employee/userselet';
const defaultForm = { const defaultForm = {
@ -152,11 +149,7 @@ export default {
this.getTypeOptions() this.getTypeOptions()
}, },
mounted() {
this.list = this.$route.query.employeelist;
this.formData.employees = this.$route.query.employeelist;
console.log( this.list)
},
methods: { methods: {
@ -169,10 +162,19 @@ export default {
closeMoule(e) { closeMoule(e) {
this.formData.employees = e,
this.dialogVisible = false
this.type_employees = e;
this.dialogVisible = false;
var arrTemp = [];
var arrName = [];
for(let i=0;i<e.length;i++){
arrTemp.push(e[i].id);
arrName.push(e[i].name);
}
this.formData.employees = arrTemp;
this.formData.employeeList=arrName
} }
, ,
submitForm() { submitForm() {

View File

@ -54,14 +54,15 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="选择学员" prop="employees"> <el-form-item label="选择学员" prop="employees">
<el-input v-model="formData.employees" readonly="readonly" clearable :style="{width: '80%'}">
</el-input> <!--<el-lable v-for="(item,index) in type_employees" :key="index">{{item.name}},</el-lable>-->
<el-input v-model="formData.employeeList" placeholder="参加人员" clearable :style="{width: '80%'}"></el-input>
<el-button type="text" @click="dialogVisible = true">选择</el-button> <el-button type="text" @click="dialogVisible = true">选择</el-button>
<el-dialog title="" :visible.sync="dialogVisible"> <el-dialog title="" :visible.sync="dialogVisible">
<Userselet @closeMoule="closeMoule"></Userselet> <Userselet @closeMoule="closeMoule"></Userselet>
</el-dialog> </el-dialog>
<SpeciesAnalyzed @closeMoule="closeMoule"></SpeciesAnalyzed>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -119,12 +120,10 @@
</div> </div>
</template> </template>
<script> <script>
import {getEmployee} from "@/api/employee"
import { createTrain,getTrain} from "@/api/train"; import { createTrain ,getTrain,updateTrain} from "@/api/train";
import { getDictList } from "@/api/dict"; import { getDictList } from "@/api/dict";
import { genTree } from "@/utils"; import { genTree } from "@/utils";
import { getOrgAll } from "@/api/org"
import { getRoleAll } from "@/api/role"
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Userselet from '@/views/employee/userselet'; import Userselet from '@/views/employee/userselet';
@ -148,46 +147,45 @@
watch: {}, watch: {},
created() { created() {
this.formData.id = this.$route.query.id , //接收参数 this.formData.id = this.$route.query.id , //接收参数
this.getData(), this.getTypeOptions(),
this.getTypeOptions() this.getData()
}, },
mounted() {
this.list = this.$route.query.employeelist;
this.formData.employees = this.$route.query.employeelist;
console.log(this.list)
},
methods: { methods: {
getData() { getData() { getTrain(this.formData.id).then(response => { this.formData = response.data;
this.formData.employeeList = response.data.employees_user_name }) },
getTrain(this.formData.id).then(response => {
this.formData = response.data
})
},
getTypeOptions() { getTypeOptions() {
getDictList({ type__code: "train_type" }).then(response => { getDictList({ type__code: "train_type" }).then(response => {
this.type_Options = genTree(response.data); this.type_Options = genTree(response.data);
}); });
}, },
closeMoule(e) { closeMoule(e) {
this.formData.employees = e,
this.dialogVisible = false
this.type_employees = e;
this.dialogVisible = false;
var arrTemp = [];
var arrName = [];
for (let i = 0; i < e.length; i++) {
arrTemp.push(e[i].id);
arrName.push(e[i].name);
}
this.formData.employees = arrTemp;
this.formData.employeeList = arrName
} }
, ,
submitForm() { submitForm() {
this.$refs["elForm"].validate(valid => { this.$refs["elForm"].validate(valid => {
if (!valid) return; if (!valid) return;
// TODO 提交表单 // TODO 提交表单
createTrain(this.formData).then(response => { updateTrain(this.formData.id,this.formData).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',

View File

@ -1,6 +1,4 @@
<template> <template>
<div class="app-container"> <div class="app-container">
@ -53,34 +51,38 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-col> </el-col>
<el-col :span="2" style="text-align:center;"> <el-col :span="2" style="text-align:center;margin-top:20px">
<el-button @click="addStaff" <el-button @click="addStaff"
type="primary" type="primary"
:disabled="!staffData.length" :disabled="!staffData.length"
icon="el-icon-arrow-right" icon="el-icon-arrow-right"
circle></el-button> circle></el-button>
<el-button @click="removeStaff" <!--<el-button @click="removeStaff"
type="primary" type="primary"
:disabled="!selectedStaffData.length" :disabled="!selectedStaffData.length"
icon="el-icon-arrow-left" icon="el-icon-arrow-left"
circle circle
style="margin-left: 0;margin-top: 10px;"></el-button> style="margin-left: 0;margin-top: 10px;"></el-button>-->
</el-col> </el-col>
<el-col :span="5"> <el-col :span="5">
<el-table ref="selectedStaffTable" <el-table ref="selectedStaffTable"
v-loading="listLoading" v-loading="listLoading"
:key="tableKey"
:data="selectedStaffList" :data="selectedStaffList"
border border
fit fit
highlight-current-row highlight-current-row
@selection-change="handleSelectedStaffChange"> >
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
<el-table-column label="姓名" align="center"> <el-table-column label="姓名" align="center">
<template slot-scope="{row}"> <template slot-scope="{row}">
<span>{{ row.user.name }}</span> <span>{{ row.user.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button type="danger" icon="el-icon-delete" circle @click.native.prevent="deleteRow(scope.$index, selectedStaffList)"></el-button>
</template>
</el-table-column>
</el-table> </el-table>
</el-col> </el-col>
@ -93,19 +95,11 @@
</template> </template>
<script> <script>
import { getEmployeeList, deleteEmployee } from "@/api/employee" import { getEmployeeList, deleteEmployee } from "@/api/employee"
import checkPermission from '@/utils/permission'
import { getUserList} from "@/api/user"
import { getDictList } from "@/api/dict"
import { genTree } from "@/utils" import { genTree } from "@/utils"
import { getOrgAll } from "@/api/org" import { getOrgAll } from "@/api/org"
import { getRoleAll } from "@/api/role"
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css" import "@riophae/vue-treeselect/dist/vue-treeselect.css"
import { upUrl, upHeaders } from "@/api/file"
const defaultForm = {
}
export default { export default {
components: {}, components: {},
props: [], props: [],
@ -137,10 +131,7 @@ data() {
selectedStaffData: [], selectedStaffData: [],
tableKey: 0, tableKey: 0,
rowKey: "rowKey", rowKey: "rowKey",
staffOptions: [
{ key: 28, display_name: "组长" },
{ key: 29, display_name: "组员" }
],
} }
}, },
watch: { watch: {
@ -169,8 +160,10 @@ methods: {
this.listLoading = false this.listLoading = false
}) })
}, },
deleteRow(index, rows) {
rows.splice(index, 1);
}
,
handleOrgClick(obj, node, vue) { handleOrgClick(obj, node, vue) {
this.listQuery.page = 1; this.listQuery.page = 1;
this.listQuery.dept = obj.id; this.listQuery.dept = obj.id;
@ -204,7 +197,7 @@ methods: {
}, 0); }, 0);
let repeat = false; let repeat = false;
this.selectedStaffList.forEach(item => { this.selectedStaffList.forEach(item => {
if (this.staffData[0] && item.name === this.staffData[0].name) { if (this.staffData[0] && item.id === this.staffData[0].id) {
repeat = true; repeat = true;
alert("此员工已添加"); alert("此员工已添加");
return; return;
@ -247,34 +240,41 @@ methods: {
} }
} }
} }
}, },
// 将右边表格选择项存入selectedStaffData中 // 将右边表格选择项存入selectedStaffData中
handleSelectedStaffChange(rows) { //handleSelectedStaffChange(rows) {
this.selectedStaffData = []; // this.selectedStaffData = [];
if (rows) { // if (rows) {
rows.forEach(row => { // rows.forEach(row => {
if (row) { // if (row) {
this.selectedStaffData.push(row); // this.selectedStaffData.push(row);
} // }
}); // });
} // }
}, //},
// 提交 // 提交
modifyStaff() { modifyStaff() {
console.log(this.selectedStaffList); console.log(this.selectedStaffList);
var userlist = []; var userlist = [];
var userNameList = [];
for (let i = 0; i < this.selectedStaffList.length; i++) {
userlist[i]=this.selectedStaffList[i].id var arrContact = new Array();
userNameList[i]= this.selectedStaffList[i].user.name for (let i = 0; i < this.selectedStaffList.length; i++) {
var reVal = new Object();
reVal["id"]=this.selectedStaffList[i].id
reVal["name"]=this.selectedStaffList[i].user.name
arrContact.push(reVal);
} }
this.$emit('closeMoule',userlist) userlist=arrContact;
this.$emit('closeMoule',userlist,)
this.dialogVisible = false this.dialogVisible = false

View File

@ -397,7 +397,7 @@
linkman1_mobile: undefined, linkman1_mobile: undefined,
linkman1_tel: undefined, linkman1_tel: undefined,
linkman1_fax: undefined, linkman1_fax: undefined,
linkman_email: undefined, linkman1_email: undefined,
linkman2_name: undefined, linkman2_name: undefined,
linkman2_duty: undefined, linkman2_duty: undefined,
linkman2_mobile: undefined, linkman2_mobile: undefined,
@ -419,8 +419,14 @@
type_Options: [], type_Options: [],
rule1: { rule1: {
query_code: [{ required: true, message: '请输入组织查询码', trigger: 'blur' }], query_code: [{ required: true, message: '请输入组织查询码', trigger: 'blur' }],
code: [{ required: true, message: '请输入工厂编号', trigger: 'blur' }] code: [{ required: true, message: '请输入工厂编号', trigger: 'blur' }],
name: [{ required: true, message: '请输入组织名称', trigger: 'blur' }],
linkman1_email:[
{ required: true, message: '请输入邮箱地址', trigger: 'blur' },
{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
],
}, },
field101Options: [], field101Options: [],

View File

@ -419,7 +419,12 @@
type_Options: [], type_Options: [],
rule1: { rule1: {
query_code: [{ required: true, message: '请输入组织查询码', trigger: 'blur' }], query_code: [{ required: true, message: '请输入组织查询码', trigger: 'blur' }],
code: [{ required: true, message: '请输入工厂编号', trigger: 'blur' }] code: [{ required: true, message: '请输入工厂编号', trigger: 'blur' }],
name: [{ required: true, message: '请输入组织名称', trigger: 'blur' }],
linkman1_email:[
{ required: true, message: '请输入邮箱地址', trigger: 'blur' },
{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
],
}, },
field101Options: [], field101Options: [],
field101Props: { field101Props: {

View File

@ -6,7 +6,7 @@ import uuid
# Create your models here. # Create your models here.
class Enterprise(CommonBModel): class Enterprise(CommonBModel):
code = models.CharField('工厂编号',unique=True, max_length=300) code = models.CharField('工厂编号',unique=True, max_length=300)
name = models.CharField('工厂名称',null=True, blank=True,max_length=1000) name = models.CharField('工厂名称',null=True,unique=True, blank=True,max_length=1000)
ename = models.CharField('工厂英文名称',null=True, blank=True,max_length=1000) ename = models.CharField('工厂英文名称',null=True, blank=True,max_length=1000)
type = models.ForeignKey(Dict, on_delete=models.SET_NULL,null=True, blank=True,verbose_name='机构类型', related_name= 'enterprise_type') type = models.ForeignKey(Dict, on_delete=models.SET_NULL,null=True, blank=True,verbose_name='机构类型', related_name= 'enterprise_type')
legal = models.CharField('申请单位法人代表',null=True, blank=True,max_length=300) legal = models.CharField('申请单位法人代表',null=True, blank=True,max_length=300)

View File

@ -77,6 +77,9 @@ class TrainSerializer(serializers.ModelSerializer):
""" """
普通序列化 普通序列化
""" """
employees_user_name = serializers.StringRelatedField(source='employees',read_only=True, many=True)
class Meta: class Meta:
model = Train model = Train
fields = '__all__' fields = ['id', 'name', 'start_time', 'end_time', 'hours',
'train_org', 'teacher', 'content', 'rain_address', 'kaohe_type', 'remark', 'employees', 'employees_user_name']