index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar :title="config.title">
  6. <!-- #ifndef MP-WEIXIN -->
  7. <button class="button white-btn" @click="handleSave">
  8. 保存
  9. </button>
  10. <!-- #endif -->
  11. </wk-nav-bar>
  12. <view class="container">
  13. <template v-if="type === 'pass' && auditInfo.examineType === 2">
  14. <wk-select-list
  15. v-model="auditType"
  16. :list="options"
  17. :max="1"
  18. class="select-list"
  19. @change="handleChange" />
  20. <view v-if="showNext" class="select-user">
  21. <wk-field-user
  22. v-model="auditUser"
  23. :field="userField" />
  24. </view>
  25. </template>
  26. <view :class="{margin: ['cancel', 'refuse'].includes(type)}" class="textarea-box">
  27. <wk-field-textarea
  28. v-model.trim="form.remarks"
  29. :field="textareaField"
  30. :placeholder="config.placeholder" />
  31. </view>
  32. </view>
  33. <!-- #ifdef MP-WEIXIN -->
  34. <view class="footer-btn-group">
  35. <button class="button" @click="handleSave">
  36. 保存
  37. </button>
  38. </view>
  39. <!-- #endif -->
  40. </view>
  41. <uni-popup ref="popup" type="dialog">
  42. <uni-popup-dialog
  43. :content="dialogMsg"
  44. :duration="2000"
  45. type="warning"
  46. @confirm="handleConfirm" />
  47. </uni-popup>
  48. </view>
  49. </template>
  50. <script>
  51. import WkFieldUser from '@/components/wk-form/wk-field-user.vue'
  52. import WkFieldTextarea from '@/components/wk-form/wk-field-textarea.vue'
  53. export default {
  54. name: 'AuditIndex',
  55. components: {
  56. WkFieldUser,
  57. WkFieldTextarea
  58. },
  59. data() {
  60. return {
  61. type: '',
  62. routerQuery: {},
  63. options: [
  64. {label: '结束审核', value: 'over'},
  65. {label: '选择下一审批人', value: 'next'}
  66. ],
  67. auditType: [],
  68. userField: {
  69. formType: 'single_user',
  70. name: '下一审批人',
  71. value: [],
  72. },
  73. textareaField: {
  74. formType: 'textarea',
  75. name: '',
  76. value: '',
  77. },
  78. form: {},
  79. auditInfo: {},
  80. auditUser: [],
  81. dialogMsg: ''
  82. }
  83. },
  84. computed: {
  85. showNext() {
  86. if (this.$isEmpty(this.auditType)) return false
  87. return this.auditType[0].value === 'next'
  88. },
  89. config() {
  90. if (this.type === 'pass') {
  91. return {title: '通过审核', placeholder: '请输入审核意见(选填)'}
  92. } else if (this.type === 'refuse') {
  93. return {title: '拒绝审核', placeholder: '请输入审核意见(必填)'}
  94. } else if (this.type === 'cancel') {
  95. return {title: '撤回审核', placeholder: '请输入撤回原因(必填)'}
  96. }
  97. return {title: '', placeholder: ''}
  98. },
  99. },
  100. onLoad(options) {
  101. this.routerQuery = options
  102. this.type = options.type
  103. this.auditType = [this.options[0]]
  104. this.auditInfo = getApp().globalData.auditInfo
  105. },
  106. onUnload() {
  107. getApp().globalData.auditInfo = {}
  108. },
  109. methods: {
  110. handleChange(data) {
  111. // if (data.length > 0) {
  112. // this.auditType = [data[0].value]
  113. // }
  114. },
  115. handleChangeUser(data) {},
  116. handleSave() {
  117. if (this.showNext && this.auditUser.length > 0) {
  118. this.form.nextUserId = this.auditUser[0].userId
  119. }
  120. if (['refuse', 'cancel'].includes(this.type) && !this.form.remarks) {
  121. this.$toast('请先完善审批信息')
  122. return
  123. }
  124. if (this.showNext && !this.form.nextUserId) {
  125. this.$toast('请先选择下一个审批人')
  126. return
  127. }
  128. const map = {
  129. pass: 1, // 通过
  130. refuse: 2, // 拒绝
  131. cancel: 4, // 撤回
  132. }
  133. this.form.status = map[this.type]
  134. // console.log(this.form)
  135. this.dialogMsg = this.type === 'cancel' ? '您确定要撤销审批吗' : '您确定要进行审核吗?'
  136. this.$refs.popup.open()
  137. },
  138. handleConfirm() {
  139. this.$refs.popup.close()
  140. uni.$emit('save-audit', this.form)
  141. this.$Router.navigateBack()
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped lang="scss">
  147. .main-container {
  148. .container {
  149. flex: 1;
  150. padding: 20rpx 0;
  151. .select-user, .textarea-box {
  152. padding: 0 30rpx 15rpx;
  153. background-color: white;
  154. margin-top: 20rpx;
  155. }
  156. .textarea-box {
  157. padding-top: 15rpx;
  158. }
  159. .select-user, .textarea-box.margin {
  160. margin-top: 0;
  161. }
  162. }
  163. }
  164. </style>