detail.vue 8.6 KB

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