5c5b2fd560543adb7f79e4b45bb277de37ce5e03.svn-base 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <!-- 任务分配 -->
  3. <el-dialog title="任务分配" :visible.sync="taskDialogVisible" @close="closeTaskDialog">
  4. <el-form label-width="120px">
  5. <el-form-item label="机构">
  6. <el-select v-model="orgId" placeholder="请选择" @change="orgChange">
  7. <el-option
  8. :label="item.orgNm"
  9. :value="item.orgId"
  10. v-for="(item,index) in orgList"
  11. :key="index"
  12. ></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="督查对象类型">
  16. <!--<el-form-item label="督查对象类型" v-show="bindObjList.length">-->
  17. <el-checkbox :indeterminate="isIndeterminate" v-model="selectAll" @change="handleCheckAllChange">全选</el-checkbox>
  18. <el-checkbox-group v-model="checkList" @change="checkboxChange">
  19. <el-checkbox :label="item.inspName" v-for="(item,index) in objList" :key="index"></el-checkbox>
  20. </el-checkbox-group>
  21. </el-form-item>
  22. </el-form>
  23. <div slot="footer" class="dialog-footer">
  24. <el-button @click="taskDialogVisible = false">取 消</el-button>
  25. <el-button type="primary" @click="addTask">确 定</el-button>
  26. </div>
  27. </el-dialog>
  28. </template>
  29. <script>
  30. import request from '@util/gw_ajax_request.js'
  31. export default {
  32. props: ['personTaskInfo'],
  33. data() {
  34. return {
  35. orgList: [],
  36. objList: [],
  37. checkList: [],
  38. orgId: '',
  39. taskDialogVisible: true,
  40. selectAll: false, //是否全选
  41. bindObjList: [],
  42. isIndeterminate: true
  43. }
  44. },
  45. computed: {
  46. persId() {
  47. return localStorage.getItem('userid') ? localStorage.getItem('userid') : ''
  48. },
  49. },
  50. mounted() {
  51. this.getOrgList()
  52. },
  53. methods: {
  54. addTask() {
  55. let paramObj = []
  56. if (this.checkList.length) {
  57. this.objList.forEach(elem => {
  58. this.checkList.forEach(ele => {
  59. if (elem.inspName == ele) {
  60. paramObj.push({
  61. 'persId': this.personTaskInfo.persId,
  62. 'orgId': this.orgId,
  63. 'name': ele,
  64. 'code': elem.inspType
  65. })
  66. }
  67. })
  68. })
  69. request.post(`/bis/insp/add/inspType`, paramObj).then(res => {
  70. if (res.success) {
  71. this.$message.success('绑定成功')
  72. this.$emit('closeTaskDialog')
  73. } else {
  74. this.$message.error(res.message)
  75. }
  76. })
  77. } else {
  78. request.post(`/bis/insp/add/inspType?delPersId=${this.personTaskInfo.persId}&delOrgId=${this.orgId}`,[]).then(res => {
  79. if (res.success) {
  80. this.$message.success('操作成功')
  81. this.$emit('closeTaskDialog')
  82. } else {
  83. this.$message.error(res.message)
  84. }
  85. })
  86. }
  87. },
  88. closeTaskDialog() {
  89. this.$emit('closeTaskDialog')
  90. },
  91. getObjList(orgId) {
  92. let val = orgId;
  93. request.get(`/bis/insp/rel/org/insp/type/getInspTypeByOrgId/${val}`)
  94. .then(res => {
  95. this.$nextTick(() => {
  96. if (res.success) {
  97. this.objList = res.data;
  98. this.getCurInfo()
  99. }
  100. })
  101. })
  102. },
  103. getOrgList() {
  104. let orgIds = this.personTaskInfo.orgIds.split(',')
  105. let orgNames = this.personTaskInfo.orgNames.split(',')
  106. orgIds.forEach((ele, index) => {
  107. this.orgList.push({'orgId': ele, 'orgNm': orgNames[index]})
  108. })
  109. this.orgId = this.personTaskInfo.orgIds?orgIds[0]:"";
  110. this.getObjList(this.orgId)
  111. },
  112. // 查询当前已选择的督查类
  113. getCurInfo() {
  114. this.checkList = []
  115. request.get(`/bis/insp/list/${this.orgId}/${this.personTaskInfo.persId}`).then(res => {
  116. if (res.success) {
  117. this.$nextTick(()=>{
  118. this.bindObjList = res.data
  119. this.bindObjList.forEach(ele => {
  120. this.objList.forEach(elem => {
  121. if (ele.id == elem.inspType) {
  122. this.checkList.push(elem.inspName)
  123. }
  124. })
  125. })
  126. console.log(this.checkList);
  127. console.log(this.objList)
  128. })
  129. } else {
  130. this.$message.error(res.message)
  131. }
  132. })
  133. },
  134. handleCheckAllChange(val) {
  135. this.checkList = val ? this.objList : [];
  136. this.isIndeterminate = false;
  137. if (val) {
  138. this.checkList = []
  139. this.objList.forEach(ele => {
  140. this.checkList.push(ele.inspName)
  141. })
  142. } else {
  143. this.checkList = []
  144. }
  145. },
  146. checkboxChange(value) {
  147. let checkedCount = value.length;
  148. this.selectAll = checkedCount === this.objList.length;
  149. this.isIndeterminate = checkedCount > 0 && checkedCount < this.objList.length;
  150. },
  151. orgChange(val) {
  152. console.log(val);
  153. this.getObjList(val)
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped>
  159. </style>