detail.vue 8.0 KB

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