approvalTasks.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <view>
  3. <!-- 顶部 -->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">审批任务</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class=" flex justify-center">
  9. <button @click="save()" class="margin-top-ssm cu-btn text-white line-blue round">提交</button>
  10. </view>
  11. </block>
  12. </cu-custom>
  13. <!-- 内容 -->
  14. <form>
  15. <view class="cu-form-group" @click="modalShow=true">
  16. <view class="title">审批意见</view>
  17. <input placeholder="请选择" v-model="opinion" name="input" disabled=""></input>
  18. <text class='cuIcon-right text-gray'></text>
  19. </view>
  20. <view class="cu-form-group align-start">
  21. <view class="title">备注</view>
  22. <textarea maxlength="-1" v-model="remarks" placeholder="请输入"></textarea>
  23. </view>
  24. </form>
  25. <form v-if="taskData.task_flow == null||taskData.task_flow ==1">
  26. <view v-if="radio == 1" class="cu-form-group margin-top-sm" @click="navNext()">
  27. <view class="title">下一审批人</view>
  28. <input placeholder="请选择" v-model="approve" disabled="" ></input>
  29. <text class='cuIcon-right'></text>
  30. </view>
  31. <view v-if="radio == 2" class="cu-form-group margin-top-sm" @click="navBack()">
  32. <view class="title">退回人员</view>
  33. <input placeholder="请选择" v-model="approve" disabled="" ></input>
  34. <text class='cuIcon-right'></text>
  35. </view>
  36. </form>
  37. <!-- 弹窗 -->
  38. <view class="cu-modal bottom-modal" :class="modalShow?'show':''" >
  39. <view class="cu-dialog" style="background-color: white;">
  40. <view class="cu-bar bg-white">
  41. <view class="action text-gray"></view>
  42. <view class="action text-black text-bold" style="color: #101010;">选择审批意见</view>
  43. <view class="action text-gray" @tap="modalShow=false">取消</view>
  44. </view>
  45. <view class="">
  46. <radio-group class="block" @change="RadioChange">
  47. <view class="cu-list menu text-left" v-for="(item,index) in radioList" :key="index">
  48. <view class="cu-item" v-if="index!=2">
  49. <label class="flex justify-between align-center flex-sub">
  50. <view class="flex-sub">{{item.name}}</view>
  51. <radio class="round" :class="radio==item.vlaue ?'checked':''" :checked="radio==item.vlaue ? true:false"
  52. :value="item.value"></radio>
  53. </label>
  54. </view>
  55. <view class="cu-item" v-else-if="index==2 && choose" >
  56. <label class="flex justify-between align-center flex-sub">
  57. <view class="flex-sub" style="color: #101010;">{{item.name}}</view>
  58. <radio class="round" :class="radio==item.vlaue ?'checked':''" :checked="radio==item.vlaue ? true:false"
  59. :value="item.value"></radio>
  60. </label>
  61. </view>
  62. </view>
  63. </radio-group>
  64. </view>
  65. </view>
  66. </view>
  67. <uni-popup ref="popup1" type="dialog">
  68. <view class="padding-top radius bg-white" style="width: 660rpx;">
  69. <view class="text-center" style="font-size: 36rpx;">短信验证</view>
  70. <view class="cu-form-group">
  71. <view class="title">绑定手机</view>
  72. <input placeholder="" name="input" :value="signType.isPhone" disabled></input>
  73. </view>
  74. <view class="cu-form-group">
  75. <view class="title">验证码</view>
  76. <input placeholder="请输入短信验证码" name="input" @input="onKeyInput"></input>
  77. <button class='cu-btn round' v-if="sendCoded">{{timeOutNum}}s</button>
  78. <button class='cu-btn round line-blue' v-else @tap="toMobileByCode">获取验证码</button>
  79. </view>
  80. <view class="flex flex-wrap text-center" style="border-top:1px solid #eee;">
  81. <view class="basis-df padding-tb" style="border-right: 1px solid #eee;" @tap="hideDialong">取消</view>
  82. <view class="basis-df padding-tb text-blue" @tap="checkSms">确定</view>
  83. </view>
  84. </view>
  85. </uni-popup>
  86. </view>
  87. </template>
  88. <script>
  89. import rangeDatetime from "@/components/range-datetime.vue";
  90. export default {
  91. components: {
  92. rangeDatetime,
  93. },
  94. data() {
  95. return {
  96. modalShow:false,
  97. show:true,
  98. opinion:"",
  99. radio: 0,
  100. approve:"",//人员,
  101. approveId:"",
  102. radioList:[{name:"同意",value:'1'},{name:"不同意",value:'2'},{name:"同意并结束流程",value:'3'}],
  103. taskData:{},
  104. choose:true,
  105. remarks:"",
  106. userInfo:"",
  107. project:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id),
  108. signType:{
  109. isOpenSign:0,//合同是否开启电签,0关闭,1开启
  110. isPfxFile:'',//是否有证书文件,1有
  111. isPhone:'',//绑定的手机号,没有则没绑定
  112. },
  113. smscode:'',
  114. sendCoded:false,//
  115. timeOutId:null,
  116. timeOutNum:60,
  117. formDataIds:'',
  118. contractIdList:'',
  119. }
  120. },
  121. onLoad(e) {
  122. this.userInfo = uni.getStorageSync("userInfo");
  123. if(e.taskId){
  124. //单个任务
  125. this.finTaskSingle(e.taskId);
  126. this.signType.isOpenSign = (e.isOpenSign);
  127. this.signType.isPfxFile = (e.isPfxFile);
  128. this.signType.isPhone = (e.isPhone);
  129. }else{
  130. this.formDataIds = e.formDataIds;
  131. this.contractIdList = e.contractIdList;
  132. this.taskData.task_flow = e.task_flow;
  133. this.getSignType();
  134. }
  135. //console.log(this.signType)
  136. },
  137. methods: {
  138. save(){
  139. var that =this;
  140. if(that.radio!=0){
  141. if(this.taskData.task_flow == null||this.taskData.task_flow ==1){
  142. //如果是自定义流程 必须选人员
  143. if(!that.approveId){
  144. if(that.radio==1){
  145. that.$prompt.none("请选择下一审批人");
  146. return;
  147. }
  148. if(that.radio==2){
  149. that.$prompt.none("请选择退回人员");
  150. return;
  151. }
  152. }
  153. }
  154. if(that.radio==1 || that.radio==3){//同意 || //同意并结束
  155. // if(that.approveId!=""){
  156. //
  157. // }else{
  158. // that.$prompt.none("请选择下一审批人")
  159. // }
  160. //不开启电签
  161. if(this.signType.isOpenSign != 1 ||
  162. this.signType.isPfxFile != '1'
  163. ){
  164. that.saveData(that.radio);
  165. }
  166. //开启电签可是需要绑定手机
  167. if(this.signType.isOpenSign == 1 &&
  168. this.signType.isPfxFile == '1' &&
  169. (!this.signType.isPhone || this.signType.isPhone.length != 11)
  170. ){
  171. uni.showModal({
  172. title: '提示',
  173. content: '当前账号未绑定手机,或手机号不正确,无法通过APP端进行电签,请通过PC端使用UKEY进行电签'
  174. });
  175. return;
  176. }
  177. //开启电签,短信验证
  178. if(this.signType.isOpenSign == 1 &&
  179. this.signType.isPfxFile == '1' &&
  180. this.signType.isPhone.length == 11
  181. ){
  182. //是否超时
  183. this.http.request("/app/sms/checkSmsTimeout",{userId:this.userInfo.id,phone:this.signType.isPhone}).then((res)=>{
  184. if(res.result=="-1"){
  185. this.$refs.popup1.open();
  186. }
  187. if(res.result == '1'){
  188. //未超时
  189. that.saveData(that.radio);
  190. }
  191. })
  192. }
  193. }else if(that.radio==2){ //不同意
  194. if(that.remarks){
  195. that.saveData(that.radio);
  196. }else{
  197. that.$prompt.none("请输入备注内容")
  198. }
  199. }
  200. }else{
  201. that.$prompt.none("请选择审批意见")
  202. }
  203. },
  204. // saveData(type){
  205. // var that =this;
  206. // if(type==1){//同意的保存
  207. // that.http.request("/app/task/agree",{userId:that.userInfo.id,taskId:that.taskData.id,remarks:that.remarks,approveId:that.approveId}).then((res)=>{
  208. // if(res.result=="1"){
  209. // that.$prompt.none("提交成功");
  210. // setTimeout(function(){
  211. // uni.reLaunch({
  212. // url:"/pages/task/task"
  213. // })
  214. // },2000)
  215. // }else{
  216. // that.$prompt.none("提交失败");
  217. // }
  218. // })
  219. // }else if(type==2){//不同意的保存
  220. // that.http.request("/app/task/disagreeOrEnd",{taskId:that.taskData.id,remarks:that.remarks}).then((res)=>{
  221. // if(res.result=="1"){
  222. // that.$prompt.none("提交成功");
  223. // setTimeout(function(){
  224. // uni.reLaunch({
  225. // url:"/pages/task/task"
  226. // })
  227. // },2000)
  228. // }else{
  229. // that.$prompt.none("提交失败");
  230. // }
  231. // })
  232. // }else if(type==3){//同意并结束的保存
  233. // that.http.request("/app/task/disagreeOrEnd",{taskId:that.taskData.id,remarks:""}).then((res)=>{
  234. // if(res.result=="1"){
  235. // that.$prompt.none("提交成功");
  236. // setTimeout(function(){
  237. // uni.reLaunch({
  238. // url:"/pages/task/task"
  239. // })
  240. // },2000)
  241. // }else{
  242. // that.$prompt.none("提交失败");
  243. // }
  244. // })
  245. // }
  246. // //uni.$emit("save");
  247. // },
  248. saveData(type){
  249. if(this.formDataIds){
  250. //批量审批
  251. this.batchSave(type);
  252. return;
  253. }
  254. var obj = {
  255. formDataId: this.taskData.id,
  256. taskStatus: '',
  257. userIds: this.approveId,
  258. flow: this.taskData.task_flow,
  259. remarks: this.remarks,
  260. contractId: this.taskData.contractInfoId,
  261. nowUserId:this.userInfo.id
  262. }
  263. if(type==1){//同意的保存
  264. obj.taskStatus = "1";
  265. }else if(type==2){//不同意的保存
  266. obj.taskStatus = "-1";
  267. }else if(type==3){//同意并结束的保存
  268. obj.taskStatus = "2";
  269. }
  270. this.http.request("/app/task/audit",obj).then((res)=>{
  271. if(res.result == '1'){
  272. this.$prompt.none("提交成功");
  273. setTimeout(function(){
  274. uni.reLaunch({
  275. url:"/pages/task/task"
  276. })
  277. },2000)
  278. }else{
  279. this.$prompt.none("提交失败");
  280. }
  281. })
  282. },
  283. finTaskSingle(id){
  284. var that = this;
  285. that.http.request("/app/task/findTaskSingle",{taskId:id}).then((res)=>{
  286. that.taskData = res.data;
  287. // if(that.taskData.task_flow=="固定流程"){
  288. // that.choose=false;
  289. // }
  290. if(!(that.taskData.task_flow==null || that.taskData.task_flow ==1)){
  291. that.choose=false;
  292. }
  293. //console.log(that.taskData)
  294. })
  295. },
  296. navNext(){
  297. uni.navigateTo({
  298. url:"/pages/constructionLog/personnel/personnel?name=选择审批人"
  299. })
  300. },
  301. navBack(){
  302. uni.navigateTo({
  303. url:"/pages/constructionLog/personnel/personnel?name=选择退回人员"
  304. })
  305. },
  306. RadioChange(e) {
  307. this.radio = e.detail.value;
  308. this.radioList.forEach((item,index,arry)=>{
  309. if(item.value==e.detail.value){
  310. this.opinion=item.name
  311. return
  312. }
  313. })
  314. this.approve = "";
  315. this.approveId = "";
  316. // if(this.radio==1){
  317. // this.show=true;
  318. // }else{
  319. // this.show=false;
  320. // }
  321. this.modalShow=false
  322. },
  323. //发送验证码
  324. toMobileByCode(){
  325. if(this.sendCoded){
  326. //一分钟内只给发一次请求
  327. return;
  328. }
  329. this.http.request("/app/sms/toMobileByCode",{userId:this.userInfo.id,phone:this.signType.isPhone}).then((res)=>{
  330. if(res.result=="1"){
  331. this.$prompt.none('验证码已发送');
  332. this.sendCoded = true;
  333. setTimeout(()=>{
  334. this.sendCoded = false;
  335. },60000);
  336. this.timeOutId = setInterval(()=>{
  337. this.timeOutNum--;
  338. if(this.timeOutNum < 1){
  339. clearInterval(this.timeOutId)
  340. this.timeOutNum = 60;
  341. }
  342. console.log(this.timeOutNum);
  343. },1000)
  344. }else{
  345. this.$prompt.none(res.msg);
  346. }
  347. })
  348. },
  349. //验证短信验证码
  350. checkSms(){
  351. console.log(this.smscode)
  352. this.http.request("/app/sms/checkSms",{userId:this.userInfo.id,phone:this.signType.isPhone,code:this.smscode}).then((res)=>{
  353. if(res.result=="1"){
  354. //通过
  355. this.saveData(this.radio);
  356. }else{
  357. this.$prompt.none(res.msg);
  358. }
  359. })
  360. },
  361. hideDialong(){
  362. this.$refs.popup1.close();
  363. },
  364. onKeyInput(value){
  365. //console.log(value)
  366. this.smscode = value.detail.value;
  367. },
  368. getSignType(){
  369. let userInfo = uni.getStorageSync("userInfo");
  370. let porject = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  371. this.http.request("/app/task/findtaskByTypeList",{
  372. userId:userInfo.id ,
  373. contractId:porject.contractId
  374. }).then((res)=>{
  375. this.signType = res.data;
  376. })
  377. },
  378. //批量审批
  379. batchSave(type){
  380. var obj = {
  381. formDataIds: this.formDataIds,
  382. taskStatus: '',
  383. userIds: this.approveId,
  384. flow: this.taskData.task_flow,
  385. remarks: this.remarks,
  386. contractIdList: this.contractIdList,
  387. contractId: this.project.contractId,
  388. nowUserId:this.userInfo.id
  389. }
  390. if(type==1){//同意的保存
  391. obj.taskStatus = "1";
  392. }else if(type==2){//不同意的保存
  393. obj.taskStatus = "-1";
  394. }else if(type==3){//同意并结束的保存
  395. obj.taskStatus = "2";
  396. }
  397. this.http.request("/app/task/auditList",obj).then((res)=>{
  398. if(res.result == '1'){
  399. this.$prompt.none("提交成功");
  400. setTimeout(function(){
  401. uni.reLaunch({
  402. url:"/pages/task/task"
  403. })
  404. },2000)
  405. }else{
  406. this.$prompt.none("提交失败");
  407. }
  408. })
  409. }
  410. },
  411. onShow() {
  412. uni.$on("approve", res =>{
  413. //console.log(res)
  414. this.approveId = res[0].id;
  415. this.approve=res[0].user_name;
  416. })
  417. }
  418. }
  419. </script>
  420. <style>
  421. .cu-modal.show {
  422. overflow-y: auto;
  423. pointer-events: auto;
  424. }
  425. .cu-form-group .title {
  426. min-width: calc(4em + 15px);
  427. }
  428. </style>