detail.vue 8.3 KB

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