e04f79e75f58cf4a7af11fbe22f2bfcfe8d163d6.svn-base 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <el-dialog
  3. title="关联督查组"
  4. top="20vh"
  5. append-to-body
  6. :visible.sync="dialogVisible"
  7. width="50%"
  8. :before-close="handleClose">
  9. <el-form :inline="true" :model="searchForm" class="demo-form-inline" size="mini">
  10. <el-form-item label="业务">
  11. <el-select v-model="searchForm.type" placeholder="督查业务" clearable>
  12. <el-option :label="item.name" :value="item.id" v-for="item in DCTypeOption" :key="item.id"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="批次" v-if="searchForm.type">
  16. <el-select v-model="searchForm.batch" placeholder="批次" clearable>
  17. <el-option :label="item.pnm" :value="item.id" v-for="item in batchList" :key="item.id"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. </el-form>
  21. <el-input
  22. placeholder="输入关键字进行过滤"
  23. v-model="filterText">
  24. </el-input>
  25. <el-tree
  26. v-loading="loading"
  27. class="filter-tree"
  28. style="height:40vh;overflow:auto"
  29. :highlight-current="true"
  30. :data="treeData"
  31. node-key="id"
  32. :filter-node-method="filterNode"
  33. ref="tree"
  34. :expand-on-click-node="false"
  35. @node-click="handleNodeClick">
  36. <div class="custom-tree-node" slot-scope="{ node, data }">
  37. <span style="float:left;">{{data.nm}} </span>
  38. <i style="margin-left: 30px;" class="el-icon-success group_select" v-if="groupId == data.id"></i>
  39. </div>
  40. </el-tree>
  41. <span slot="footer" class="dialog-footer">
  42. <el-button @click="dialogVisible = false">取 消</el-button>
  43. <el-button type="primary" @click="comfirm">确 定</el-button>
  44. </span>
  45. </el-dialog>
  46. </template>
  47. <script>
  48. import {getTreeDataApi,connectToPlanApi} from '@api/zhxxAPI.js'
  49. import {getTrees} from '@util/gw_formatTree.js'
  50. import {getPersPlanType} from '@api/duChaPlan.js'
  51. import {getBatchByType} from '@api/zhxxApi.js'
  52. export default {
  53. props: ['roadbookId'],
  54. data(){
  55. return{
  56. dialogVisible: true,
  57. treeData: [],
  58. defaultProps: {
  59. children: 'children',
  60. nm: 'label'
  61. },
  62. groupId: '',
  63. groupNm: '',
  64. filterText: '',
  65. loading: false,
  66. searchForm:{
  67. type: '',
  68. batch: ''
  69. }, //督查组过滤条件
  70. DCTypeOption: null,
  71. batchList: []
  72. }
  73. },
  74. computed:{
  75. persId(){
  76. return localStorage.getItem("userid") ? localStorage.getItem("userid") : "";
  77. }
  78. },
  79. mounted(){
  80. this.getTreeData()
  81. this.getUserPlanType()
  82. this.getbatchList()
  83. },
  84. methods:{
  85. // 获取督查组数据
  86. getTreeData(){
  87. let data = {
  88. persid: this.persId,
  89. ptype: this.searchForm.type,
  90. pid: this.searchForm.batch
  91. }
  92. this.loading = true
  93. getTreeDataApi(data).then(res=>{
  94. this.loading = false
  95. if(res.success){
  96. this.treeData = getTrees(res.data)
  97. }else{
  98. this.$message.warning(res.message)
  99. }
  100. }).catch(err=>{
  101. })
  102. },
  103. comfirm(){
  104. if(!this.groupId){
  105. this.$message.info('请选择要关联的督查组')
  106. return
  107. }
  108. this.$confirm('确认关联到当前督查组吗?', '提示', {
  109. confirmButtonText: '确定',
  110. cancelButtonText: '取消',
  111. type: 'warning'
  112. }).then(() => {
  113. let data = {
  114. id: this.roadbookId,
  115. planId: this.groupId,
  116. planNm: this.groupNm
  117. }
  118. connectToPlanApi(data).then((res)=>{
  119. if(res.success){
  120. this.$message.success('关联成功')
  121. this.$emit('closeGroupsDialog')
  122. }else{
  123. this.$message.warning(res.message)
  124. }
  125. })
  126. }).catch(() => {
  127. });
  128. },
  129. handleClose(){
  130. this.$emit('closeGroupsDialog')
  131. },
  132. handleNodeClick(data) {
  133. console.log(data);
  134. this.groupId = data.id
  135. this.groupNm = data.nm
  136. },
  137. filterNode(value, data) {
  138. if (!value) return true;
  139. if(data.nm == null) data.nm = ''
  140. return data.nm.indexOf(value) !== -1;
  141. },
  142. // 督查业务类型列表获取
  143. getUserPlanType(){
  144. let _self = this;
  145. getPersPlanType(this.persId).then(res =>{
  146. this.DCTypeOption = res.data;
  147. });
  148. },
  149. //获取批次数据
  150. getBatchList(){
  151. getBatchByType(this.persId,this.searchForm.type).then(res => {
  152. this.batchList = res.data;
  153. });
  154. },
  155. },
  156. watch: {
  157. filterText(val) {
  158. this.$refs.tree.filter(val);
  159. },
  160. 'searchForm.type':{
  161. deep: true,
  162. handler(val){
  163. if(!val) this.searchForm.batch = ''
  164. this.getTreeData()
  165. if(val)this.getBatchList()
  166. }
  167. },
  168. 'searchForm.batch':{
  169. deep: true,
  170. handler(val){
  171. if(val) this.getTreeData()
  172. }
  173. }
  174. },
  175. }
  176. </script>
  177. <style lang="scss">
  178. .el-icon-success.group_select{
  179. color: #67C23A;
  180. }
  181. </style>