detail.vue 8.7 KB

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