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-table ref="table" border stripe>
  17. <uni-tr>
  18. <uni-th align="center">采购物资名称</uni-th>
  19. <uni-th align="center" width="80">采购数量</uni-th>
  20. <uni-th align="center">预算金额(元)</uni-th>
  21. </uni-tr>
  22. <uni-tr v-for="(item, index) in form.oaPurchaseObjs" :key="index">
  23. <uni-td align="center">
  24. {{item.name}}
  25. </uni-td>
  26. <uni-td align="center">
  27. {{item.amount}}
  28. </uni-td>
  29. <uni-td align="center">
  30. {{item.budget}}
  31. </uni-td>
  32. </uni-tr>
  33. </uni-table>
  34. <uni-forms-item label="总预算金额(元)">
  35. <uni-easyinput v-model="form.totalBudget" disabled />
  36. </uni-forms-item>
  37. <uni-forms-item label="预期供应商">
  38. <uni-easyinput v-model="form.supplierName" disabled />
  39. </uni-forms-item>
  40. <uni-forms-item label="采购事由">
  41. <uni-easyinput autoHeight type="textarea" v-model="form.reason" disabled />
  42. </uni-forms-item>
  43. <uni-forms-item label="附件">
  44. <view class="upload-wrap">
  45. <view class="mgb-16 file-wrap" v-for="(item, index) in form.fileList" :key="index">
  46. <view class="btn-click file-line" @click="handlePreview(item)">
  47. <view class="file-info">
  48. <image :src="icons.file" mode="aspectFill" class="file-icon" />
  49. <text class="file-name">{{ item.name || title[type] }}</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </uni-forms-item>
  55. <uni-forms-item label="备注">
  56. <uni-easyinput autoHeight maxlength="200" type="textarea" v-model="form.remarks" disabled />
  57. </uni-forms-item>
  58. <uni-forms-item label="审批意见" required v-if="(form.auditStatus==2 || form.auditStatus==1) && name=='0'">
  59. <uni-easyinput autoHeight maxlength="200" type="textarea" v-model="reason" placeholder="请输入审批建议" />
  60. </uni-forms-item>
  61. <uni-forms-item label="流程动态">
  62. <uni-steps active-icon="medal" :options="tasks" active-color="#007AFF" :active="tasks.length" direction="column" />
  63. </uni-forms-item>
  64. </uni-forms>
  65. <view class="button-group" v-if="name=='0'">
  66. <button type="primary" size="mini" @click="handleAudit(true)">同意</button>
  67. <button size="mini" @click="handleAudit(false)">驳回</button>
  68. </view>
  69. <view class="button-group" v-if="name=='2'">
  70. <button type="warning" size="mini" @click="handleRevocation('form')">撤回</button>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import { getDetail,revocation,agree,disagree } from "@/api/oa/purchase.js"
  76. export default {
  77. props: {
  78. id: {
  79. type: [String, Number],
  80. default: undefined
  81. },
  82. name: {
  83. type: String,
  84. default: undefined
  85. },
  86. },
  87. data() {
  88. return {
  89. reason:'',
  90. active: -1,
  91. tasks: [],
  92. userInfo:uni.getStorageSync('userInfo'),
  93. alignment:'top',
  94. fileList: [],
  95. icons: {
  96. file: '/static/icon_file.png',
  97. },
  98. // 表单数据
  99. form: {},
  100. }
  101. },
  102. watch: {
  103. id: {
  104. immediate: true,
  105. handler(val) {
  106. this.getDetail(val);
  107. }
  108. }
  109. },
  110. methods: {
  111. /** 获得详情信息 */
  112. getDetail(val) {
  113. getDetail(val).then(response => {
  114. this.form = response.data;
  115. let auditRecordList = response.data.auditRecordList;
  116. let tasks = [];
  117. auditRecordList.forEach(v => {
  118. tasks.push({
  119. title:'任务:' + v.assigneeUser.nickname + v.name,
  120. desc:this.parseTime(v.endTime),
  121. })
  122. })
  123. this.tasks = tasks;
  124. });
  125. },
  126. // 预览
  127. handlePreview(val) {
  128. console.log('PreviewFile', val);
  129. const fileType = this.getFileType(val.name);
  130. if (fileType === 'image') {
  131. uni.previewImage({
  132. current: 0,
  133. urls: [val.url],
  134. });
  135. }
  136. else if (fileType === 'office') {
  137. return uni.downloadFile({
  138. url: val.url,
  139. success: function (res) {
  140. let filePath = res.filePath || res.tempFilePath;
  141. uni.openDocument({
  142. filePath: filePath,
  143. showMenu: true,
  144. success: function (res) {
  145. console.log('打开文档成功');
  146. }
  147. });
  148. }
  149. });
  150. }
  151. else{
  152. uni.showModal({
  153. title: '该类型文件无法预览',
  154. content: val.name,
  155. showCancel: false,
  156. });
  157. }
  158. },
  159. handleRevocation(){
  160. console.log(this.form.taskId);
  161. let that = this
  162. uni.showModal({
  163. title: '提示',
  164. content: '是否确认撤回?',
  165. success: function (res) {
  166. if (res.confirm) {
  167. console.log('用户点击确定');
  168. revocation({id:that.form.taskId}).then(response => {
  169. uni.showToast({
  170. title: "撤回成功!"
  171. })
  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>