detail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="container">
  3. <uni-forms ref="form" :model="form" labelWidth="80px" :label-position="alignment">
  4. <uni-forms-item label="申请人">
  5. <uni-easyinput v-model="form.employeeName" disabled />
  6. </uni-forms-item>
  7. <uni-forms-item label="部门">
  8. <uni-easyinput v-model="form.deptName" disabled />
  9. </uni-forms-item>
  10. <uni-forms-item label="职位">
  11. <uni-easyinput v-model="form.position" disabled />
  12. </uni-forms-item>
  13. <uni-forms-item label="手机号">
  14. <uni-easyinput v-model="form.employeePhone" disabled />
  15. </uni-forms-item>
  16. <uni-forms-item label="事项标题">
  17. <uni-easyinput maxlength="20" v-model="form.title" disabled />
  18. </uni-forms-item>
  19. <uni-forms-item label="详细描述">
  20. <uni-easyinput autoHeight maxlength="200" type="textarea" v-model="form.description" disabled />
  21. </uni-forms-item>
  22. <uni-forms-item label="附件">
  23. <view class="upload-wrap">
  24. <view class="mgb-16 file-wrap" v-for="(item, index) in form.fileList" :key="index">
  25. <view class="btn-click file-line" @click="handlePreview(item)">
  26. <view class="file-info">
  27. <image :src="icons.file" mode="aspectFill" class="file-icon" />
  28. <text class="file-name">{{ item.name || title[type] }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </uni-forms-item>
  34. <uni-forms-item label="备注">
  35. <uni-easyinput autoHeight maxlength="200" type="textarea" v-model="form.remarks" disabled />
  36. </uni-forms-item>
  37. <uni-forms-item label="审批意见" required v-if="(form.auditStatus==2 || form.auditStatus==1) && name=='0'">
  38. <uni-easyinput autoHeight maxlength="200" type="textarea" v-model="reason" placeholder="请输入审批建议" />
  39. </uni-forms-item>
  40. <uni-forms-item label="流程动态">
  41. <uni-steps active-icon="medal" :options="tasks" active-color="#007AFF" :active="tasks.length" direction="column" />
  42. </uni-forms-item>
  43. </uni-forms>
  44. <view class="button-group" v-if="name=='0'">
  45. <button type="primary" size="mini" @click="handleAudit(true)">同意</button>
  46. <button size="mini" @click="handleAudit(false)">驳回</button>
  47. </view>
  48. <view class="button-group" v-if="name=='2'">
  49. <button type="warning" v-if="form.auditStatus==1" size="mini" @click="handleRevocation('form')">撤回</button>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { getDetail,revocation,agree,disagree } from "@/api/oa/universal.js"
  55. export default {
  56. props: {
  57. id: {
  58. type: [String, Number],
  59. default: undefined
  60. },
  61. name: {
  62. type: String,
  63. default: undefined
  64. },
  65. },
  66. data() {
  67. return {
  68. reason:'',
  69. active: -1,
  70. tasks: [],
  71. userInfo:uni.getStorageSync('userInfo'),
  72. alignment:'top',
  73. fileList: [],
  74. icons: {
  75. file: '/static/icon_file.png',
  76. },
  77. // 表单数据
  78. form: {},
  79. }
  80. },
  81. watch: {
  82. id: {
  83. immediate: true,
  84. handler(val) {
  85. this.getDetail(val);
  86. }
  87. }
  88. },
  89. methods: {
  90. /** 获得详情信息 */
  91. getDetail(val) {
  92. getDetail(val).then(response => {
  93. this.form = response.data;
  94. let auditRecordList = response.data.auditRecordList;
  95. let tasks = [];
  96. auditRecordList.forEach(v => {
  97. tasks.push({
  98. title:'任务:' + v.assigneeUser.nickname + v.name,
  99. desc:this.parseTime(v.endTime),
  100. })
  101. })
  102. this.tasks = tasks;
  103. });
  104. },
  105. // 预览
  106. handlePreview(val) {
  107. console.log('PreviewFile', val);
  108. const fileType = this.getFileType(val.name);
  109. if (fileType === 'image') {
  110. uni.previewImage({
  111. current: 0,
  112. urls: [val.url],
  113. });
  114. }
  115. else if (fileType === 'office') {
  116. return uni.downloadFile({
  117. url: val.url,
  118. success: function (res) {
  119. let filePath = res.filePath || res.tempFilePath;
  120. uni.openDocument({
  121. filePath: filePath,
  122. showMenu: true,
  123. success: function (res) {
  124. console.log('打开文档成功');
  125. }
  126. });
  127. }
  128. });
  129. }
  130. else{
  131. uni.showModal({
  132. title: '该类型文件无法预览',
  133. content: val.name,
  134. showCancel: false,
  135. });
  136. }
  137. },
  138. handleRevocation(){
  139. console.log(this.form.taskId);
  140. let that = this
  141. uni.showModal({
  142. title: '提示',
  143. content: '是否确认撤回?',
  144. success: function (res) {
  145. if (res.confirm) {
  146. console.log('用户点击确定');
  147. revocation({id:that.form.taskId}).then(response => {
  148. uni.showToast({
  149. title: "撤回成功!"
  150. })
  151. that.$emit('popupClose');
  152. })
  153. } else if (res.cancel) {
  154. console.log('用户点击取消');
  155. }
  156. }
  157. });
  158. },
  159. handleAudit(pass) {
  160. if (!this.reason) {
  161. uni.showModal({
  162. title: "提示",
  163. content: "请填写审批意见",
  164. showCancel: false,
  165. confirmText: "确定"
  166. })
  167. return;
  168. } else {
  169. const data = {
  170. id: this.form.taskId,
  171. reason: this.reason,
  172. }
  173. if (pass) {
  174. agree(data).then(response => {
  175. uni.showToast({
  176. title: "审批通过成功!"
  177. })
  178. this.$emit('popupClose');
  179. });
  180. } else {
  181. disagree(data).then(response => {
  182. uni.showToast({
  183. title: "驳回成功!"
  184. })
  185. this.$emit('popupClose');
  186. });
  187. }
  188. }
  189. },
  190. }
  191. }
  192. </script>
  193. <style lang="scss">
  194. .container {
  195. padding: 15px;
  196. background-color: #fff;
  197. }
  198. .segmented-control {
  199. margin-bottom: 15px;
  200. }
  201. .button-group {
  202. margin-top: 15px;
  203. display: flex;
  204. }
  205. .form-item {
  206. display: flex;
  207. align-items: center;
  208. flex: 1;
  209. }
  210. .button {
  211. display: flex;
  212. align-items: center;
  213. height: 35px;
  214. line-height: 35px;
  215. margin-left: 10px;
  216. }
  217. </style>
  218. <style lang="scss" scoped>
  219. .user-avatar {
  220. width: 22px;
  221. height: 22px;
  222. line-height: 19px;
  223. font-size: 12px;
  224. background: #46c26f;
  225. border: 1px solid transparent;
  226. border-radius: 5px;
  227. color: #fff;
  228. display: inline-block;
  229. overflow: hidden;
  230. text-align: center;
  231. line-height: 22px;
  232. margin-bottom: 2px;
  233. }
  234. .popup-body{
  235. z-index: 99;
  236. height: 450px;
  237. overflow-x: auto;
  238. // margin-bottom: 60px;
  239. }
  240. .popup-close{
  241. cursor: pointer;
  242. height: 40px;
  243. line-height: 40px;
  244. padding-left: 10px;
  245. border-bottom: 1px solid #eaecef;
  246. }
  247. .popup-content{
  248. margin: 20px;
  249. }
  250. .btn-click {
  251. transition: all 0.3s;
  252. opacity: 1;
  253. }
  254. .btn-click:active {
  255. opacity: 0.5;
  256. }
  257. .mgb-16 {
  258. margin-bottom: 16rpx;
  259. &:last-child {
  260. margin-bottom: 0;
  261. }
  262. }
  263. .upload-wrap {
  264. width: 100%;
  265. border-radius: 16rpx;
  266. background: white;
  267. // padding: 32rpx;
  268. .upload-btn {
  269. width: 100%;
  270. height: 176rpx;
  271. border: 2rpx dashed #AAAAAA;
  272. background: #FAFAFA;
  273. border-radius: 16rpx;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. flex-direction: column;
  278. .upload-icon {
  279. width: 48rpx;
  280. height: 48rpx;
  281. margin-bottom: 8rpx;
  282. }
  283. .upload-text {
  284. font-size: 26rpx;
  285. color: #9E9E9E;
  286. line-height: 40rpx;
  287. }
  288. }
  289. .file-wrap {
  290. .file-line {
  291. width: 100%;
  292. background: #F5F5F5;
  293. border-radius: 8rpx;
  294. padding: 16rpx;
  295. font-size: 26rpx;
  296. color: #1A1A1A;
  297. line-height: 40rpx;
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. .file-info {
  302. width: 90%;
  303. display: flex;
  304. align-items: center;
  305. .file-name {
  306. max-width: 80%;
  307. padding-left: 16rpx;
  308. overflow: hidden;
  309. text-overflow: ellipsis;
  310. white-space: nowrap;
  311. }
  312. }
  313. .file-icon {
  314. width: 40rpx;
  315. height: 40rpx;
  316. flex-shrink: 0;
  317. }
  318. .file-empty {
  319. color: #999999;
  320. }
  321. }
  322. }
  323. }
  324. </style>