detail.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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" 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. })
  152. } else if (res.cancel) {
  153. console.log('用户点击取消');
  154. }
  155. }
  156. });
  157. },
  158. handleAudit(pass) {
  159. if (!this.reason) {
  160. uni.showModal({
  161. title: "提示",
  162. content: "请填写审批意见",
  163. showCancel: false,
  164. confirmText: "确定"
  165. })
  166. return;
  167. } else {
  168. const data = {
  169. id: this.form.taskId,
  170. reason: this.reason,
  171. }
  172. if (pass) {
  173. agree(data).then(response => {
  174. uni.showToast({
  175. title: "审批通过成功!"
  176. })
  177. this.$emit('popupClose');
  178. });
  179. } else {
  180. disagree(data).then(response => {
  181. uni.showToast({
  182. title: "驳回成功!"
  183. })
  184. this.$emit('popupClose');
  185. });
  186. }
  187. }
  188. },
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. .container {
  194. padding: 15px;
  195. background-color: #fff;
  196. }
  197. .segmented-control {
  198. margin-bottom: 15px;
  199. }
  200. .button-group {
  201. margin-top: 15px;
  202. display: flex;
  203. }
  204. .form-item {
  205. display: flex;
  206. align-items: center;
  207. flex: 1;
  208. }
  209. .button {
  210. display: flex;
  211. align-items: center;
  212. height: 35px;
  213. line-height: 35px;
  214. margin-left: 10px;
  215. }
  216. </style>
  217. <style lang="scss" scoped>
  218. .user-avatar {
  219. width: 22px;
  220. height: 22px;
  221. line-height: 19px;
  222. font-size: 12px;
  223. background: #46c26f;
  224. border: 1px solid transparent;
  225. border-radius: 5px;
  226. color: #fff;
  227. display: inline-block;
  228. overflow: hidden;
  229. text-align: center;
  230. line-height: 22px;
  231. margin-bottom: 2px;
  232. }
  233. .popup-body{
  234. z-index: 99;
  235. height: 450px;
  236. overflow-x: auto;
  237. // margin-bottom: 60px;
  238. }
  239. .popup-close{
  240. cursor: pointer;
  241. height: 40px;
  242. line-height: 40px;
  243. padding-left: 10px;
  244. border-bottom: 1px solid #eaecef;
  245. }
  246. .popup-content{
  247. margin: 20px;
  248. }
  249. .btn-click {
  250. transition: all 0.3s;
  251. opacity: 1;
  252. }
  253. .btn-click:active {
  254. opacity: 0.5;
  255. }
  256. .mgb-16 {
  257. margin-bottom: 16rpx;
  258. &:last-child {
  259. margin-bottom: 0;
  260. }
  261. }
  262. .upload-wrap {
  263. width: 100%;
  264. border-radius: 16rpx;
  265. background: white;
  266. // padding: 32rpx;
  267. .upload-btn {
  268. width: 100%;
  269. height: 176rpx;
  270. border: 2rpx dashed #AAAAAA;
  271. background: #FAFAFA;
  272. border-radius: 16rpx;
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. flex-direction: column;
  277. .upload-icon {
  278. width: 48rpx;
  279. height: 48rpx;
  280. margin-bottom: 8rpx;
  281. }
  282. .upload-text {
  283. font-size: 26rpx;
  284. color: #9E9E9E;
  285. line-height: 40rpx;
  286. }
  287. }
  288. .file-wrap {
  289. .file-line {
  290. width: 100%;
  291. background: #F5F5F5;
  292. border-radius: 8rpx;
  293. padding: 16rpx;
  294. font-size: 26rpx;
  295. color: #1A1A1A;
  296. line-height: 40rpx;
  297. display: flex;
  298. align-items: center;
  299. justify-content: space-between;
  300. .file-info {
  301. width: 90%;
  302. display: flex;
  303. align-items: center;
  304. .file-name {
  305. max-width: 80%;
  306. padding-left: 16rpx;
  307. overflow: hidden;
  308. text-overflow: ellipsis;
  309. white-space: nowrap;
  310. }
  311. }
  312. .file-icon {
  313. width: 40rpx;
  314. height: 40rpx;
  315. flex-shrink: 0;
  316. }
  317. .file-empty {
  318. color: #999999;
  319. }
  320. }
  321. }
  322. }
  323. </style>