personnel.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view>
  3. <!-- 顶部 -->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">{{titleName}}</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class=" flex justify-center">
  9. <button @click="navTo()" class="cu-btn round line-blue text-white" style="width: 160rpx;height: 66rpx;padding: 0;">确定({{num}})</button>
  10. </view>
  11. </block>
  12. </cu-custom>
  13. <!-- 内容 -->
  14. <checkboxTree v-if="type==0" :selectList="selectList"></checkboxTree>
  15. <radioTree v-else :selectList="selectList" ref="radiotree"></radioTree>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. titleName:"选择施工员",
  23. num:0,
  24. selectList:[
  25. {name: '施工方',checked:false,show:true,children:[]},
  26. {name: '监理',checked:false,show:false,children:[]},
  27. {name: '业主',checked:false,show:false,children:[]}],
  28. type:0
  29. }
  30. },
  31. deep:true,
  32. methods: {
  33. navTo(){
  34. //刷新确定的选择的数据
  35. let choose =[];
  36. if(this.type!=0){//单选类型
  37. this.selectList.forEach(item => {
  38. item.children.forEach((items)=>{
  39. if(items.checked){
  40. choose.push(items)
  41. }
  42. })
  43. });
  44. if(choose.length>=2){
  45. choose =choose[choose.length-1];
  46. let index = [];
  47. index.push(choose)
  48. choose=index.concat();
  49. }
  50. }else{//多选类型
  51. this.selectList.forEach(item => {
  52. item.children.forEach((items)=>{
  53. if(items.checked){
  54. choose.push(items)
  55. }
  56. })
  57. });
  58. }
  59. if(choose.length==0){
  60. this.$prompt.none("请选择人员");
  61. return;
  62. }
  63. if(this.type==1 && this.titleName=="选择施工员"){//施工
  64. uni.$emit("handleFun",choose);
  65. }
  66. else if(this.type==2 && this.titleName=="选择监理员"){//监理
  67. uni.$emit("handleFunBy",choose);
  68. }
  69. else if((this.titleName=="选择负责人") && this.type==0){
  70. //console.log(this.selectList);
  71. uni.$emit("principal",choose)
  72. }
  73. else if(this.titleName=="选择审批人" && this.type==1){
  74. uni.$emit("approve",choose)
  75. }else if(this.titleName=="选择退回人员" && this.type==1){
  76. uni.$emit("approve",choose)
  77. }else if(this.titleName=="选择任务人" && this.type==1){
  78. uni.$emit("taskPerson",choose)
  79. }
  80. else if(this.titleName=="选择人员"){
  81. uni.$emit("principal",choose)
  82. }
  83. else if(this.titleName=="选择抄送人"){
  84. uni.$emit("copyPerson",choose)
  85. }
  86. uni.navigateBack({
  87. delta:1
  88. })
  89. },
  90. /* 获取施工员和监理员 */
  91. findUserType(type){
  92. var that =this;
  93. that.selectList=[];
  94. var contractId = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId;
  95. that.http.request('/app/diary/listByType', {type:type,contractId:contractId}).then((result)=>{
  96. if(result.datas!=null){
  97. if(type==1){//施工员
  98. that.selectList=[{name: '施工方',checked:false,show:true,children:[]}];
  99. }else{//监理员
  100. that.selectList=[{name: '监理方',checked:false,show:true,children:[]}];
  101. }
  102. result.datas.forEach((item,index,arr)=>{
  103. item.checked=false;
  104. })
  105. that.selectList[0].children=result.datas;
  106. }
  107. })
  108. },
  109. /* 获取负责人(获取1为施工方、 2为监理方 3、为业主方)*/
  110. findUserTypeOne(){
  111. var that=this;
  112. var contractId = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId;
  113. this.http.request("/app/task/listByTask",{contractId:contractId}).then((res)=>{
  114. res.datas.forEach((item,index,arr)=>{
  115. item.checked=false;
  116. if(item.type==1){
  117. this.selectList[0].children.push(item)
  118. }else if(item.type==2){
  119. this.selectList[1].children.push(item)
  120. }else if(item.type==3){
  121. this.selectList[2].children.push(item)
  122. }
  123. })
  124. //把已选的添加上
  125. if(this.titleName=="选择负责人" ||
  126. this.titleName=="选择审批人" ||
  127. this.titleName=="选择抄送人" ||
  128. this.titleName=="选择人员" ||
  129. this.titleName=="选择任务人"){
  130. let selects = getApp().globalData.principal;
  131. //console.log(selects)
  132. this.num = selects.length;
  133. selects.forEach((sele)=>{
  134. let index = 0;
  135. if(sele.type==1){
  136. index = 0;
  137. }else if(sele.type==2){
  138. index = 1;
  139. }else if(sele.type==3){
  140. index = 2;
  141. }
  142. this.selectList[index].children.forEach((person)=>{
  143. if(person.id == sele.id){
  144. person.checked = true;
  145. if(that.$refs.radiotree){
  146. that.$refs.radiotree.RadioChange(index,person)
  147. }
  148. }
  149. })
  150. })
  151. }
  152. })
  153. }
  154. },
  155. onLoad(e) {
  156. if(e.type){
  157. if(e.type==1){
  158. this.titleName ="选择施工员";
  159. this.findUserType(e.type);
  160. }
  161. if(e.type==2){
  162. this.titleName ="选择监理员";
  163. this.findUserType(e.type);
  164. }
  165. this.type=e.type
  166. }else{
  167. this.titleName =e.name;
  168. if(this.titleName=="选择负责人"){
  169. this.findUserTypeOne();
  170. }else if(this.titleName=="选择人员"){
  171. this.findUserTypeOne();
  172. }else if(this.titleName=="选择抄送人"){
  173. this.findUserTypeOne();
  174. }else if(this.titleName=="选择退回人员"){
  175. this.type=1;//单选
  176. this.findUserTypeOne();
  177. }else{//选择审批人
  178. this.type=1;//单选
  179. this.findUserTypeOne();
  180. }
  181. }
  182. /* 全局事件订阅,只要订阅了事件就可以收到值 */
  183. uni.$on("num",(rel)=>{
  184. this.num=rel
  185. })
  186. }
  187. }
  188. </script>
  189. <style>
  190. </style>