detail.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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" v-if="form.auditStatus==1" 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. that.$emit('popupClose');
  173. })
  174. } else if (res.cancel) {
  175. console.log('用户点击取消');
  176. }
  177. }
  178. });
  179. },
  180. handleAudit(pass) {
  181. if (!this.reason) {
  182. uni.showModal({
  183. title: "提示",
  184. content: "请填写审批意见",
  185. showCancel: false,
  186. confirmText: "确定"
  187. })
  188. return;
  189. } else {
  190. const data = {
  191. id: this.form.taskId,
  192. reason: this.reason,
  193. }
  194. if (pass) {
  195. agree(data).then(response => {
  196. uni.showToast({
  197. title: "审批通过成功!"
  198. })
  199. this.$emit('popupClose');
  200. });
  201. } else {
  202. disagree(data).then(response => {
  203. uni.showToast({
  204. title: "驳回成功!"
  205. })
  206. this.$emit('popupClose');
  207. });
  208. }
  209. }
  210. },
  211. }
  212. }
  213. </script>
  214. <style lang="scss">
  215. .container {
  216. padding: 15px;
  217. background-color: #fff;
  218. }
  219. .segmented-control {
  220. margin-bottom: 15px;
  221. }
  222. .button-group {
  223. margin-top: 15px;
  224. display: flex;
  225. }
  226. .form-item {
  227. display: flex;
  228. align-items: center;
  229. flex: 1;
  230. }
  231. .button {
  232. display: flex;
  233. align-items: center;
  234. height: 35px;
  235. line-height: 35px;
  236. margin-left: 10px;
  237. }
  238. </style>
  239. <style lang="scss" scoped>
  240. .user-avatar {
  241. width: 22px;
  242. height: 22px;
  243. line-height: 19px;
  244. font-size: 12px;
  245. background: #46c26f;
  246. border: 1px solid transparent;
  247. border-radius: 5px;
  248. color: #fff;
  249. display: inline-block;
  250. overflow: hidden;
  251. text-align: center;
  252. line-height: 22px;
  253. margin-bottom: 2px;
  254. }
  255. .popup-body{
  256. z-index: 99;
  257. height: 450px;
  258. overflow-x: auto;
  259. // margin-bottom: 60px;
  260. }
  261. .popup-close{
  262. cursor: pointer;
  263. height: 40px;
  264. line-height: 40px;
  265. padding-left: 10px;
  266. border-bottom: 1px solid #eaecef;
  267. }
  268. .popup-content{
  269. margin: 20px;
  270. }
  271. .btn-click {
  272. transition: all 0.3s;
  273. opacity: 1;
  274. }
  275. .btn-click:active {
  276. opacity: 0.5;
  277. }
  278. .mgb-16 {
  279. margin-bottom: 16rpx;
  280. &:last-child {
  281. margin-bottom: 0;
  282. }
  283. }
  284. .upload-wrap {
  285. width: 100%;
  286. border-radius: 16rpx;
  287. background: white;
  288. // padding: 32rpx;
  289. .upload-btn {
  290. width: 100%;
  291. height: 176rpx;
  292. border: 2rpx dashed #AAAAAA;
  293. background: #FAFAFA;
  294. border-radius: 16rpx;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. flex-direction: column;
  299. .upload-icon {
  300. width: 48rpx;
  301. height: 48rpx;
  302. margin-bottom: 8rpx;
  303. }
  304. .upload-text {
  305. font-size: 26rpx;
  306. color: #9E9E9E;
  307. line-height: 40rpx;
  308. }
  309. }
  310. .file-wrap {
  311. .file-line {
  312. width: 100%;
  313. background: #F5F5F5;
  314. border-radius: 8rpx;
  315. padding: 16rpx;
  316. font-size: 26rpx;
  317. color: #1A1A1A;
  318. line-height: 40rpx;
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. .file-info {
  323. width: 90%;
  324. display: flex;
  325. align-items: center;
  326. .file-name {
  327. max-width: 80%;
  328. padding-left: 16rpx;
  329. overflow: hidden;
  330. text-overflow: ellipsis;
  331. white-space: nowrap;
  332. }
  333. }
  334. .file-icon {
  335. width: 40rpx;
  336. height: 40rpx;
  337. flex-shrink: 0;
  338. }
  339. .file-empty {
  340. color: #999999;
  341. }
  342. }
  343. }
  344. }
  345. </style>