| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <!-- 任务分配 -->
- <el-dialog title="任务分配" :visible.sync="taskDialogVisible" @close="closeTaskDialog">
- <el-form label-width="120px">
- <el-form-item label="机构">
- <el-select v-model="orgId" placeholder="请选择" @change="orgChange">
- <el-option
- :label="item.orgNm"
- :value="item.orgId"
- v-for="(item,index) in orgList"
- :key="index"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="督查对象类型">
- <!--<el-form-item label="督查对象类型" v-show="bindObjList.length">-->
- <el-checkbox :indeterminate="isIndeterminate" v-model="selectAll" @change="handleCheckAllChange">全选</el-checkbox>
- <el-checkbox-group v-model="checkList" @change="checkboxChange">
- <el-checkbox :label="item.inspName" v-for="(item,index) in objList" :key="index"></el-checkbox>
- </el-checkbox-group>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="taskDialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="addTask">确 定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import request from '@util/gw_ajax_request.js'
- export default {
- props: ['personTaskInfo'],
- data() {
- return {
- orgList: [],
- objList: [],
- checkList: [],
- orgId: '',
- taskDialogVisible: true,
- selectAll: false, //是否全选
- bindObjList: [],
- isIndeterminate: true
- }
- },
- computed: {
- persId() {
- return localStorage.getItem('userid') ? localStorage.getItem('userid') : ''
- },
- },
- mounted() {
- this.getOrgList()
- },
- methods: {
- addTask() {
- let paramObj = []
- if (this.checkList.length) {
- this.objList.forEach(elem => {
- this.checkList.forEach(ele => {
- if (elem.inspName == ele) {
- paramObj.push({
- 'persId': this.personTaskInfo.persId,
- 'orgId': this.orgId,
- 'name': ele,
- 'code': elem.inspType
- })
- }
- })
- })
- request.post(`/bis/insp/add/inspType`, paramObj).then(res => {
- if (res.success) {
- this.$message.success('绑定成功')
- this.$emit('closeTaskDialog')
- } else {
- this.$message.error(res.message)
- }
- })
- } else {
- request.post(`/bis/insp/add/inspType?delPersId=${this.personTaskInfo.persId}&delOrgId=${this.orgId}`,[]).then(res => {
- if (res.success) {
- this.$message.success('操作成功')
- this.$emit('closeTaskDialog')
- } else {
- this.$message.error(res.message)
- }
- })
- }
- },
- closeTaskDialog() {
- this.$emit('closeTaskDialog')
- },
- getObjList(orgId) {
- let val = orgId;
- request.get(`/bis/insp/rel/org/insp/type/getInspTypeByOrgId/${val}`)
- .then(res => {
- this.$nextTick(() => {
- if (res.success) {
- this.objList = res.data;
- this.getCurInfo()
- }
- })
- })
- },
- getOrgList() {
- let orgIds = this.personTaskInfo.orgIds.split(',')
- let orgNames = this.personTaskInfo.orgNames.split(',')
- orgIds.forEach((ele, index) => {
- this.orgList.push({'orgId': ele, 'orgNm': orgNames[index]})
- })
- this.orgId = this.personTaskInfo.orgIds?orgIds[0]:"";
- this.getObjList(this.orgId)
- },
- // 查询当前已选择的督查类
- getCurInfo() {
- this.checkList = []
- request.get(`/bis/insp/list/${this.orgId}/${this.personTaskInfo.persId}`).then(res => {
- if (res.success) {
- this.$nextTick(()=>{
- this.bindObjList = res.data
- this.bindObjList.forEach(ele => {
- this.objList.forEach(elem => {
- if (ele.id == elem.inspType) {
- this.checkList.push(elem.inspName)
- }
- })
- })
- console.log(this.checkList);
- console.log(this.objList)
- })
- } else {
- this.$message.error(res.message)
- }
- })
- },
- handleCheckAllChange(val) {
- this.checkList = val ? this.objList : [];
- this.isIndeterminate = false;
- if (val) {
- this.checkList = []
- this.objList.forEach(ele => {
- this.checkList.push(ele.inspName)
- })
- } else {
- this.checkList = []
- }
- },
- checkboxChange(value) {
- let checkedCount = value.length;
- this.selectAll = checkedCount === this.objList.length;
- this.isIndeterminate = checkedCount > 0 && checkedCount < this.objList.length;
- },
- orgChange(val) {
- console.log(val);
- this.getObjList(val)
- }
- }
- }
- </script>
- <style scoped>
- </style>
|