ffa17cbcdfc8cc4790313bb813a5399d34f71e91.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <!-- 弹出窗 -->
  3. <el-dialog title="添加参会人员" :before-close="closeMemberDialog" :visible.sync="dialogFormVisible" width="80%">
  4. <el-container>
  5. <el-aside width="200px" style="border:1px solid #d5d5ff">
  6. <p style="font-weight:bolder;background-color:#d5d5ff;padding:3px;">
  7. <i class="el-icon-share"></i>所属督查组
  8. </p>
  9. <el-tree
  10. :highlight-current="true"
  11. style="height:100%;"
  12. :data="treeData"
  13. node-key="id"
  14. :expand-on-click-node="false"
  15. @node-click = 'treeNodeClickHandler'
  16. :props="defaultProps"
  17. ref="jigou_tree">
  18. </el-tree>
  19. </el-aside>
  20. <el-main style="border:1px solid #d5d5ff;margin-left:5px;padding:0px;">
  21. <p style="font-weight:bolder;background-color:#d5d5ff;padding:3px;">督查人员</p>
  22. <el-form style="padding:10px">
  23. <div>
  24. <el-form size="mini" :inline="true" class="demo-form-inline">
  25. <el-form-item label="人员名称">
  26. <el-input
  27. style="width:140px;"
  28. v-model="searchNameOfMemberName"
  29. clearable
  30. placeholder="请输入人员名称"
  31. ></el-input>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button type="primary" @click="refreshCurrentShow">查询</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-table
  38. ref="multipleTable"
  39. v-if="type == 'checkbox'"
  40. border
  41. v-loading="loading"
  42. :data="currentShowList"
  43. tooltip-effect="dark"
  44. style="width: 100%"
  45. @select="isSelected"
  46. @selection-change="handleSelectionChange">
  47. <el-table-column align="center" type="selection" width="70"></el-table-column>
  48. <el-table-column align="center" type="index" label="序号" min-width="45">
  49. <template slot-scope="scope">
  50. {{ (pageIndex - 1) * pageSize + (scope.$index + 1) }}
  51. </template>
  52. </el-table-column>
  53. <el-table-column align="center" show-overflow-tooltip prop="persName" label="人员姓名" min-width="80"></el-table-column>
  54. <el-table-column align="center" show-overflow-tooltip prop="orgNm" label="机构名称" min-width="100"></el-table-column>
  55. <el-table-column align="center" show-overflow-tooltip prop="admDuty" label="职务" min-width="100"></el-table-column>
  56. <el-table-column align="center" show-overflow-tooltip prop="dpnm" label="部门名称" min-width="100"></el-table-column>
  57. <el-table-column align="center" show-overflow-tooltip prop="dppost" label="职称" min-width="100"></el-table-column>
  58. <el-table-column align="center" show-overflow-tooltip prop="sex" label="性别" :formatter="sexFormatter" min-width="50"></el-table-column>
  59. <el-table-column align="center" show-overflow-tooltip prop="mobilenumb" label="手机号" min-width="100"></el-table-column>
  60. </el-table>
  61. <el-table
  62. v-if="type == 'radio'"
  63. border
  64. v-loading="loading"
  65. :data="currentShowList"
  66. tooltip-effect="dark"
  67. style="width: 100%">
  68. <el-table-column align="center" width="70">
  69. <template slot-scope="scope">
  70. <el-radio v-model="radioSelect" :label="scope.row.guid" @change="radioChange(scope.row)">&nbsp;</el-radio>
  71. </template>
  72. </el-table-column>
  73. <el-table-column align="center" type="index" label="序号" min-width="45">
  74. <template slot-scope="scope">
  75. {{ (pageIndex - 1) * pageSize + (scope.$index + 1) }}
  76. </template>
  77. </el-table-column>
  78. <el-table-column align="center" show-overflow-tooltip prop="persName" label="人员姓名" min-width="80"></el-table-column>
  79. <el-table-column align="center" show-overflow-tooltip prop="orgNm" label="机构名称" min-width="100"></el-table-column>
  80. <el-table-column align="center" show-overflow-tooltip prop="admDuty" label="职务" min-width="100"></el-table-column>
  81. <el-table-column align="center" show-overflow-tooltip prop="dpnm" label="部门名称" min-width="100"></el-table-column>
  82. <el-table-column align="center" show-overflow-tooltip prop="dppost" label="职称" min-width="100"></el-table-column>
  83. <el-table-column align="center" show-overflow-tooltip prop="sex" label="性别" :formatter="sexFormatter" min-width="50"></el-table-column>
  84. <el-table-column align="center" show-overflow-tooltip prop="mobilenumb" label="手机号" min-width="100"></el-table-column>
  85. </el-table>
  86. <div
  87. class="block"
  88. style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding-top: 5px;background-color: #fff;">
  89. <el-pagination
  90. small
  91. @current-change="handleCurrentChange"
  92. :pager-count="5"
  93. :current-page.sync="pageIndex"
  94. :page-size="pageSize"
  95. layout="total, prev, pager, next"
  96. :total="total"
  97. ></el-pagination>
  98. </div>
  99. </div>
  100. </el-form>
  101. </el-main>
  102. </el-container>
  103. <div slot="footer" class="dialog-footer">
  104. <el-button @click="closeMemberDialog">取 消</el-button>
  105. <el-button type="primary" @click="saveChange">确 定</el-button>
  106. </div>
  107. </el-dialog>
  108. </template>
  109. <script>
  110. import request from '@util/gw_ajax_request.js';
  111. import { getTrees } from "@util/gw_formatTree.js";
  112. export default {
  113. props: ['type','members'],
  114. data() {
  115. return {
  116. treeData: [],
  117. searchNameOfMemberName: '',
  118. currentShowList: [],
  119. dialogFormVisible: true,
  120. formLabelWidth: "120",
  121. multipleSelection: [],
  122. groupId: '',
  123. memberIds: [],
  124. memberNames: [],
  125. pageIndex: 1,
  126. pageSize: 10,
  127. total: 0,
  128. loading:false,
  129. defaultProps: {
  130. children: 'children',
  131. label: 'pnm',
  132. id: 'id'
  133. },
  134. radioSelect: '',
  135. singleSeclection: {}
  136. }
  137. },
  138. mounted() {
  139. this.initMember() //初始化当前已有成员数据,使之为选中状态
  140. this.getGroupData()
  141. },
  142. computed:{
  143. userId:function(){
  144. return localStorage.getItem("userid")? localStorage.getItem("userid"): '1098101939614724096'
  145. },
  146. },
  147. methods: {
  148. //获取当前用户组数据
  149. getGroupData(){
  150. request.get(`/dc/organization/base/getAllNode?userId=${this.userId}`).then(res=>{
  151. if(res.success){
  152. this.treeData = getTrees(res.data)
  153. this.groupId = this.treeData[0].id
  154. this.getMemberList()
  155. }
  156. }).catch(res=>{
  157. })
  158. },
  159. getMemberList(){
  160. let params = {
  161. inspGroupId: this.groupId,
  162. pageSize:this.pageSize,
  163. pageNum:this.pageIndex,
  164. isAll:1,
  165. persName: this.searchNameOfMemberName
  166. }
  167. request.get(`/dc/pers/base/getListByInspGroupId`,{params:params}).then(res=>{
  168. if(res.success){
  169. let _this = this
  170. this.currentShowList = res.data.list
  171. this.total = res.data.total
  172. this.$nextTick(function () {
  173. if(this.multipleSelection.length && this.currentShowList.length){
  174. let selectedRows = []
  175. this.multipleSelection.forEach(ele=>{
  176. let guid = ele.persId ? ele.persId : ele.guid
  177. _this.currentShowList.forEach(element=>{
  178. if(guid == element.guid){
  179. selectedRows.push(element)
  180. }
  181. })
  182. })
  183. selectedRows.forEach(row => {
  184. _this.$refs.multipleTable.toggleRowSelection(row,true);
  185. });
  186. }
  187. })
  188. }
  189. }).catch(res=>{
  190. })
  191. },
  192. addObjectChange: function() {
  193. //提交当前选中对象
  194. let _this = this
  195. if(this.multipleSelection.length && this.type == 'checkbox'){
  196. this.memberIds = []
  197. this.memberNames = []
  198. this.multipleSelection.forEach(ele=>{
  199. _this.memberIds.push(ele.guid)
  200. _this.memberNames.push(ele.persName)
  201. })
  202. let personInfo = {
  203. memberIds: [],
  204. memberNames: [],
  205. allInfo: []
  206. }
  207. personInfo.memberIds = this.memberIds
  208. personInfo.memberNames = this.memberNames.join(',')
  209. personInfo.allInfo = this.multipleSelection
  210. this.$emit('sendPersonInfo',personInfo)
  211. }
  212. if(Object.keys(this.singleSeclection).length && this.type == 'radio'){
  213. let personInfo = {
  214. memberId: '',
  215. memberName: ''
  216. }
  217. personInfo.memberId = this.singleSeclection.guid
  218. personInfo.memberName = this.singleSeclection.persName
  219. this.$emit('sendPersonInfo',personInfo)
  220. }
  221. },
  222. saveChange() {
  223. this.addObjectChange();
  224. },
  225. initMember(){
  226. let oldMembers = []
  227. if(this.members.length){
  228. this.members.forEach(ele=>{
  229. oldMembers.push({'guid':ele.persId ? ele.persId : ele.guid,'persName':ele.persName})
  230. })
  231. this.multipleSelection = oldMembers;
  232. }
  233. },
  234. handleSelectionChange(val) {
  235. //this.multipleSelection不能赋值为[],因为带的有之前已选中的数据
  236. if(val.length){
  237. val.forEach(ele=>{
  238. this.multipleSelection.push({'guid':ele.persId ? ele.persId : ele.guid,'persName':ele.persName})
  239. })
  240. this.multipleSelection = this.multipleSelection
  241. }
  242. let allArr = []
  243. for(var i=0;i<this.multipleSelection.length;i++){
  244. let flag = true;
  245.   for(var j=0;j<allArr.length;j++){
  246.     if(this.multipleSelection[i].guid == allArr[j].guid){
  247.       flag = false;
  248.     };
  249.   };
  250.   if(flag){
  251.     allArr.push(this.multipleSelection[i]);
  252.   };
  253. };
  254. this.multipleSelection = allArr
  255. // this.multipleSelection = Array.from(new Set(this.multipleSelection))
  256. },
  257. isSelected(rows,row){
  258. let _this = this
  259. let selected = rows.length && rows.indexOf(row) !== -1
  260. if(!selected){
  261. this.multipleSelection.forEach((ele,index)=>{
  262. if(ele.guid == row.guid){
  263. this.multipleSelection.splice(index,1)
  264. }
  265. })
  266. }
  267. },
  268. radioChange(row){
  269. this.singleSeclection = row
  270. },
  271. handleCurrentChange(val) {
  272. this.refreshCurrentShow();
  273. },
  274. refreshCurrentShow: function() {
  275. this.getMemberList()
  276. },
  277. treeNodeClickHandler(param){
  278. this.groupId = param.id
  279. },
  280. sexFormatter: function (row, column) {
  281. return row.sex == 2 ? "女" : row.sex == 1 ? "男" : '';
  282. },
  283. closeMemberDialog(){
  284. this.$emit('closeMember')
  285. // this.multipleSelection = []
  286. },
  287. },
  288. watch: {
  289. groupId(val){
  290. this.getMemberList()
  291. }
  292. }
  293. };
  294. </script>
  295. <style>
  296. </style>