detail.vue 8.7 KB

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