detail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. let reason = v.reason?v.reason:'';
  98. let time = v.endTime?v.endTime:v.createTime;
  99. tasks.push({
  100. title:'任务:' + v.assigneeUser.nickname + v.name,
  101. desc: reason + " " + this.parseTime(time),
  102. })
  103. })
  104. this.tasks = tasks;
  105. });
  106. },
  107. // 预览
  108. handlePreview(val) {
  109. console.log('PreviewFile', val);
  110. const fileType = this.getFileType(val.name);
  111. if (fileType === 'image') {
  112. uni.previewImage({
  113. current: 0,
  114. urls: [val.url],
  115. });
  116. }
  117. else if (fileType === 'office') {
  118. return uni.downloadFile({
  119. url: val.url,
  120. success: function (res) {
  121. let filePath = res.filePath || res.tempFilePath;
  122. uni.openDocument({
  123. filePath: filePath,
  124. showMenu: true,
  125. success: function (res) {
  126. console.log('打开文档成功');
  127. }
  128. });
  129. }
  130. });
  131. }
  132. else{
  133. uni.showModal({
  134. title: '该类型文件无法预览',
  135. content: val.name,
  136. showCancel: false,
  137. });
  138. }
  139. },
  140. handleRevocation(){
  141. console.log(this.form.taskId);
  142. let that = this
  143. uni.showModal({
  144. title: '提示',
  145. content: '是否确认撤回?',
  146. success: function (res) {
  147. if (res.confirm) {
  148. console.log('用户点击确定');
  149. revocation({id:that.form.taskId}).then(response => {
  150. uni.showToast({
  151. title: "撤回成功!"
  152. })
  153. that.$emit('popupClose');
  154. })
  155. } else if (res.cancel) {
  156. console.log('用户点击取消');
  157. }
  158. }
  159. });
  160. },
  161. handleAudit(pass) {
  162. if (!this.reason) {
  163. uni.showModal({
  164. title: "提示",
  165. content: "请填写审批意见",
  166. showCancel: false,
  167. confirmText: "确定"
  168. })
  169. return;
  170. } else {
  171. const data = {
  172. id: this.form.taskId,
  173. reason: this.reason,
  174. }
  175. if (pass) {
  176. agree(data).then(response => {
  177. uni.showToast({
  178. title: "审批通过成功!"
  179. })
  180. this.$emit('popupClose');
  181. });
  182. } else {
  183. disagree(data).then(response => {
  184. uni.showToast({
  185. title: "驳回成功!"
  186. })
  187. this.$emit('popupClose');
  188. });
  189. }
  190. }
  191. },
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. .container {
  197. padding: 15px;
  198. background-color: #fff;
  199. }
  200. .segmented-control {
  201. margin-bottom: 15px;
  202. }
  203. .button-group {
  204. margin-top: 15px;
  205. display: flex;
  206. }
  207. .form-item {
  208. display: flex;
  209. align-items: center;
  210. flex: 1;
  211. }
  212. .button {
  213. display: flex;
  214. align-items: center;
  215. height: 35px;
  216. line-height: 35px;
  217. margin-left: 10px;
  218. }
  219. </style>
  220. <style lang="scss" scoped>
  221. .user-avatar {
  222. width: 22px;
  223. height: 22px;
  224. line-height: 19px;
  225. font-size: 12px;
  226. background: #46c26f;
  227. border: 1px solid transparent;
  228. border-radius: 5px;
  229. color: #fff;
  230. display: inline-block;
  231. overflow: hidden;
  232. text-align: center;
  233. line-height: 22px;
  234. margin-bottom: 2px;
  235. }
  236. .popup-body{
  237. z-index: 99;
  238. height: 450px;
  239. overflow-x: auto;
  240. // margin-bottom: 60px;
  241. }
  242. .popup-close{
  243. cursor: pointer;
  244. height: 40px;
  245. line-height: 40px;
  246. padding-left: 10px;
  247. border-bottom: 1px solid #eaecef;
  248. }
  249. .popup-content{
  250. margin: 20px;
  251. }
  252. .btn-click {
  253. transition: all 0.3s;
  254. opacity: 1;
  255. }
  256. .btn-click:active {
  257. opacity: 0.5;
  258. }
  259. .mgb-16 {
  260. margin-bottom: 16rpx;
  261. &:last-child {
  262. margin-bottom: 0;
  263. }
  264. }
  265. .upload-wrap {
  266. width: 100%;
  267. border-radius: 16rpx;
  268. background: white;
  269. // padding: 32rpx;
  270. .upload-btn {
  271. width: 100%;
  272. height: 176rpx;
  273. border: 2rpx dashed #AAAAAA;
  274. background: #FAFAFA;
  275. border-radius: 16rpx;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. flex-direction: column;
  280. .upload-icon {
  281. width: 48rpx;
  282. height: 48rpx;
  283. margin-bottom: 8rpx;
  284. }
  285. .upload-text {
  286. font-size: 26rpx;
  287. color: #9E9E9E;
  288. line-height: 40rpx;
  289. }
  290. }
  291. .file-wrap {
  292. .file-line {
  293. width: 100%;
  294. background: #F5F5F5;
  295. border-radius: 8rpx;
  296. padding: 16rpx;
  297. font-size: 26rpx;
  298. color: #1A1A1A;
  299. line-height: 40rpx;
  300. display: flex;
  301. align-items: center;
  302. justify-content: space-between;
  303. .file-info {
  304. width: 90%;
  305. display: flex;
  306. align-items: center;
  307. .file-name {
  308. max-width: 80%;
  309. padding-left: 16rpx;
  310. overflow: hidden;
  311. text-overflow: ellipsis;
  312. white-space: nowrap;
  313. }
  314. }
  315. .file-icon {
  316. width: 40rpx;
  317. height: 40rpx;
  318. flex-shrink: 0;
  319. }
  320. .file-empty {
  321. color: #999999;
  322. }
  323. }
  324. }
  325. }
  326. </style>