detail.vue 8.5 KB

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