detail.vue 8.6 KB

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