filecenter.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template name="filecenter">
  2. <view class="container">
  3. <u-navbar title="文件中心" :safeAreaInsetTop="true" leftIcon=""> </u-navbar>
  4. <view class="main">
  5. <u-subsection
  6. :list="sectionList"
  7. mode="subsection"
  8. :current="curNow"
  9. @change="sectionChange"
  10. ></u-subsection>
  11. <u-list>
  12. <u-list-item
  13. class="itemback"
  14. v-for="(item, index) in fileData"
  15. :key="index"
  16. >
  17. <div class="content flcard" @tab="openFile(item)">
  18. <view
  19. class="demo-layout bg-purple-light"
  20. style="margin-bottom: 20rpx"
  21. >
  22. <view style="margin-top: 10rpx">
  23. <text class="text-style1">{{ item.fileName }}</text>
  24. </view>
  25. </view>
  26. <view class="datacard laiyuan">
  27. <view style="margin: 20rpx 20rpx">
  28. <text class="text-style">{{ item.fileSource }}</text>
  29. </view>
  30. <view style="margin: 20rpx 20rpx; font-size: small"
  31. >文件来源</view
  32. >
  33. </view>
  34. <view class="datacard zhuangtai">
  35. <view style="margin: 20rpx 20rpx">
  36. <text class="text-style">{{ item.bpmStatus_dictText }}</text>
  37. </view>
  38. <view style="margin: 20rpx 20rpx; font-size: small"
  39. >审批状态</view
  40. >
  41. </view>
  42. <view class="datacard user">
  43. <view style="margin: 20rpx 20rpx">
  44. <text class="text-style">{{ item.createBy }}</text>
  45. </view>
  46. <view style="margin: 20rpx 20rpx; font-size: small">创建人</view>
  47. </view>
  48. <view class="datacard time">
  49. <view style="margin: 20rpx 20rpx">
  50. <text class="text-style">{{ item.createTime }}</text>
  51. </view>
  52. <view style="margin: 20rpx 20rpx; font-size: small"
  53. >上传时间</view
  54. >
  55. </view>
  56. </div>
  57. <div class="btnClass">
  58. <u-button
  59. class="btn"
  60. type="primary"
  61. shape="circle"
  62. text="审批详情"
  63. @click="detailmodal(item)"
  64. ></u-button>
  65. <u-button
  66. class="btn"
  67. type="primary"
  68. shape="circle"
  69. text="提交"
  70. @click="commitmodal(item)"
  71. ></u-button>
  72. <u-button
  73. class="btn"
  74. type="primary"
  75. shape="circle"
  76. text="撤回"
  77. @click="retractmodal(item)"
  78. ></u-button>
  79. <u-button
  80. class="btn"
  81. type="primary"
  82. shape="circle"
  83. text="下载"
  84. @click="download(item)"
  85. ></u-button>
  86. <u-button
  87. class="btn"
  88. type="primary"
  89. shape="circle"
  90. text="删除"
  91. @click="showmodal(item)"
  92. ></u-button>
  93. </div>
  94. </u-list-item>
  95. </u-list>
  96. <!-- 审批详情 -->
  97. <u-popup
  98. :show="detailShow"
  99. :closeable="true"
  100. :round="10"
  101. mode="bottom"
  102. @close="detailClose"
  103. >
  104. <view>
  105. <u--textarea
  106. v-model="value1"
  107. placeholder="请输入撤回原因"
  108. ></u--textarea>
  109. </view>
  110. </u-popup>
  111. <!-- 删除 -->
  112. <u-modal
  113. :show="show"
  114. :showCancelButton="true"
  115. :showConfirmButton="true"
  116. :content="content"
  117. @confirm="confirm"
  118. @cancel="cancel"
  119. ></u-modal>
  120. <!-- 提交 -->
  121. <u-picker
  122. :show="commitShow"
  123. :columns="columns"
  124. title="选择审批"
  125. @confirm="confirmCommit"
  126. @cancel="cancelCommit"
  127. ></u-picker>
  128. <!-- 撤回 -->
  129. <u-popup
  130. :show="showretract"
  131. closeable="true"
  132. :round="10"
  133. mode="bottom"
  134. @close="close"
  135. >
  136. <view>
  137. <u--textarea
  138. v-model="value1"
  139. placeholder="请输入撤回原因"
  140. ></u--textarea>
  141. </view>
  142. <view class="button-container">
  143. <u-button @click="cancelRetract" shape="circle">取消</u-button>
  144. <u-button @click="confirmRetract" shape="circle" type="primary"
  145. >确认</u-button
  146. >
  147. </view>
  148. </u-popup>
  149. <u-notify
  150. message="只有审批中的数据才能撤回!"
  151. :show="notifyShow"
  152. :duration="1000"
  153. ></u-notify>
  154. </view>
  155. </view>
  156. </template>
  157. <script>
  158. import api from "@/api/api";
  159. import configService from "../../common/service/config.service";
  160. import { computed } from "uview-ui/libs/mixin/mixin";
  161. export default {
  162. components: {},
  163. name: "filecenter",
  164. watch: {},
  165. data() {
  166. return {
  167. sectionList: [
  168. { name: "全部", code: 0 },
  169. { name: "待审批", code: 1 },
  170. { name: "已审批", code: 2 },
  171. ],
  172. curNow: 0,
  173. fileData: [],
  174. bpmStatus: 1, //1处理中 2 已完成 3 已驳回
  175. show: false, //删除modal
  176. content: "确定要删除吗?",
  177. selectItem: "", //选择文件
  178. showretract: false, //撤回popup
  179. value1: "", //撤回原因
  180. cancelItem: "", //撤回文件
  181. detailShow: false, //详情
  182. notifyShow: false, //撤回文件提示消息显示
  183. commitShow: false, //提交
  184. columns: [],
  185. commitItem: "", //提交文件
  186. selectFile: [],
  187. };
  188. },
  189. mounted() {
  190. this.getFileInfo();
  191. },
  192. computed: {},
  193. methods: {
  194. sectionChange(newVal) {
  195. this.curNow = newVal;
  196. if (this.curNow === 0) {
  197. // 如果选择了“全部”,返回所有文件
  198. this.bpmStatus = "";
  199. this.getFileInfo(this.bpmStatus);
  200. } else if (this.curNow === 1) {
  201. // 否则,根据curNow的值过滤文件
  202. this.bpmStatus = 1;
  203. this.getFileInfo(this.bpmStatus);
  204. } else if (this.curNow === 2) {
  205. this.bpmStatus = 2;
  206. this.getFileInfo(this.bpmStatus);
  207. }
  208. },
  209. getFileInfo(code) {
  210. var params = {
  211. bpmStatus: code,
  212. column: "createTime",
  213. fileSuffix: "",
  214. likeFileName: "",
  215. pageNo: 1,
  216. pageSize: 10000,
  217. parentId: "",
  218. selectFlag: true,
  219. sysOrgCode: "",
  220. };
  221. new Promise((resolve, reject) => {
  222. api
  223. .getFileInfo(params)
  224. .then((response) => {
  225. if (response.data.code == 200) {
  226. this.fileData = response.data.result.records;
  227. } else {
  228. reject(response);
  229. }
  230. })
  231. .catch((error) => {
  232. console.log("catch===>response", response);
  233. reject(error);
  234. });
  235. });
  236. },
  237. //查看文件内容
  238. openFile(params) {
  239. uni.downloadFile({
  240. url:
  241. configService.apiUrl +
  242. "/ventanaly-sharefile/fileServer/onlyOffice/read?id=" +
  243. params.id,
  244. success: function (res) {
  245. var filePath = res.tempFilePath;
  246. uni.openDocument({
  247. filePath: filePath,
  248. showMenu: true,
  249. success: function (res) {
  250. console.log("打开文档成功");
  251. },
  252. });
  253. },
  254. });
  255. },
  256. // //下载文件到手机
  257. download(params) {
  258. var fileiId = params.id;
  259. var params = {
  260. id: fileiId,
  261. responseType: "blob", // 期望的响应类型是Blob
  262. };
  263. new Promise((resolve, reject) => {
  264. api
  265. .downloadFile(params)
  266. .then((response) => {
  267. if (response.data.code == 200) {
  268. const blob = response.data;
  269. const fileName = params.fileName; // 替换为你的文件名和扩展名
  270. // 使用uni.saveFile保存文件
  271. uni.saveFile({
  272. tempFilePath: response.tempFilePath,
  273. content: blob,
  274. success: (saveRes) => {
  275. console.log("saved file path:", saveRes.savedFilePath);
  276. // 可以使用 uni.openDocument 打开文件(如果支持)
  277. // 或者引导用户去文件管理器中查找
  278. },
  279. fail: (err) => {
  280. console.error("save file fail:", err);
  281. },
  282. });
  283. } else {
  284. // console.log("请求下载文件失败:", err);
  285. }
  286. })
  287. .catch((error) => {
  288. reject(error);
  289. });
  290. });
  291. },
  292. // //删除文件
  293. showmodal(data) {
  294. this.selectItem = data;
  295. this.show = true;
  296. },
  297. confirm() {
  298. this.delatefile(this.selectItem);
  299. },
  300. cancel() {
  301. this.show = false;
  302. },
  303. delatefile(params) {
  304. var fileiId = params.id;
  305. new Promise((resolve, reject) => {
  306. api
  307. .delateFile({ id: fileiId })
  308. .then((response) => {
  309. if (response.data.code == 200) {
  310. this.show = false;
  311. this.getFileInfo();
  312. } else {
  313. // console.log("请求下载文件失败:", err);
  314. }
  315. })
  316. .catch((error) => {
  317. reject(error);
  318. });
  319. });
  320. },
  321. //撤回文件
  322. retractmodal(data) {
  323. this.showretract = true;
  324. this.cancelItem = data;
  325. },
  326. close() {
  327. this.showretract = false;
  328. },
  329. cancelRetract() {
  330. this.showretract = false;
  331. },
  332. confirmRetract(e) {
  333. console.log(e);
  334. var fileiId = this.cancelItem.id;
  335. var params = {
  336. tableId: fileiId,
  337. reason: this.value1,
  338. tableName: this.cancelItem.tableName,
  339. };
  340. if (this.cancelItem.bpmStatus == 1) {
  341. new Promise((resolve, reject) => {
  342. api
  343. .cancelFile(params)
  344. .then((response) => {
  345. if (response.data.code == 200) {
  346. this.showretract = false;
  347. this.getFileInfo();
  348. } else {
  349. // console.log("请求下载文件失败:", err);
  350. }
  351. })
  352. .catch((error) => {
  353. reject(error);
  354. });
  355. });
  356. } else {
  357. this.notifyShow = true;
  358. }
  359. },
  360. // 详情
  361. detailmodal() {
  362. this.detailShow = true;
  363. },
  364. detailClose() {
  365. this.detailShow = false;
  366. },
  367. // 提交
  368. commitmodal(data) {
  369. this.commitShow = true;
  370. this.commitItem = data;
  371. this.getListFile();
  372. },
  373. getListFile() {
  374. this.columns = [];
  375. var params = {
  376. zx: true,
  377. column: "createTime",
  378. order: "desc",
  379. status: 1,
  380. _t: Date.now(),
  381. };
  382. new Promise((resolve, reject) => {
  383. api
  384. .getListFile(params)
  385. .then((response) => {
  386. if (response.data.code == 200) {
  387. this.selectFile = response.data.result;
  388. this.selectFile.forEach((item) => {
  389. this.columns.push(item.id);
  390. console.log(this.columns);
  391. });
  392. } else {
  393. // console.log("请求下载文件失败:", err);
  394. }
  395. })
  396. .catch((error) => {
  397. reject(error);
  398. });
  399. });
  400. },
  401. confirmCommit() {
  402. var fileiId = this.commitItem.id;
  403. var params = {
  404. tableId: fileiId,
  405. procDefId: this.columns,
  406. };
  407. new Promise((resolve, reject) => {
  408. api
  409. .commitFile(params)
  410. .then((response) => {
  411. if (response.data.code == 200) {
  412. this.commitShow = false;
  413. this.getFileInfo();
  414. } else {
  415. // console.log("请求下载文件失败:", err);
  416. }
  417. })
  418. .catch((error) => {
  419. reject(error);
  420. });
  421. });
  422. },
  423. cancelCommit() {
  424. this.commitShow = false;
  425. },
  426. },
  427. };
  428. </script>
  429. <style scoped>
  430. .button-container {
  431. display: flex;
  432. justify-content: space-between;
  433. margin-top: 10px; /* 根据需要调整 */
  434. }
  435. button {
  436. /* 样式可以根据需要自定义 */
  437. padding: 10px 20px;
  438. background-color: #007aff;
  439. color: white;
  440. border: none;
  441. border-radius: 5px;
  442. cursor: pointer;
  443. }
  444. .main {
  445. /* margin-top: 100rpx; */
  446. margin-top: 80px;
  447. display: flex;
  448. flex-direction: column;
  449. margin-top: 80px; /* 内容区域顶部留出导航栏的高度 */
  450. }
  451. .itemback {
  452. padding: 20rpx;
  453. background-color: #ffffff;
  454. margin-bottom: 5rpx;
  455. display: flex;
  456. }
  457. .btnClass {
  458. display: flex;
  459. justify-content: space-around;
  460. margin-top: 20rpx;
  461. }
  462. .btn {
  463. border-radius: 10rpx;
  464. margin-right: 10rpx; /* 示例:添加一些右外边距,但确保它不会导致换行 */
  465. }
  466. /* 最后一个按钮不需要右外边距 */
  467. .btn:last-child {
  468. margin-right: 0;
  469. }
  470. .text-style {
  471. color: #3787fe;
  472. font-weight: bold;
  473. }
  474. .text-style1 {
  475. color: #000000;
  476. font-size: large;
  477. font-weight: bold;
  478. }
  479. .datacard {
  480. width: 48%;
  481. margin: 1%;
  482. float: left;
  483. height: 120rpx;
  484. border-radius: 10px;
  485. }
  486. .time {
  487. background: url(/static/filecenter/time.png),
  488. linear-gradient(
  489. to right,
  490. rgba(55, 135, 254, 0.08),
  491. rgba(4, 184, 255, 0.08),
  492. rgba(60, 161, 237, 0.08)
  493. );
  494. background-size: auto 100%;
  495. background-position: right;
  496. background-repeat: no-repeat;
  497. }
  498. .laiyuan {
  499. background: url(/static/filecenter/laiyuan.png),
  500. linear-gradient(
  501. to right,
  502. rgba(55, 135, 254, 0.08),
  503. rgba(4, 184, 255, 0.08),
  504. rgba(60, 161, 237, 0.08)
  505. );
  506. background-size: auto 100%;
  507. background-position: right;
  508. background-repeat: no-repeat;
  509. }
  510. .user {
  511. background: url(/static/filecenter/user.png),
  512. linear-gradient(
  513. to right,
  514. rgba(55, 135, 254, 0.08),
  515. rgba(4, 184, 255, 0.08),
  516. rgba(60, 161, 237, 0.08)
  517. );
  518. background-size: auto 100%;
  519. background-position: right;
  520. background-repeat: no-repeat;
  521. }
  522. .zhuangtai {
  523. background: url(/static/filecenter/zhuangtai.png),
  524. linear-gradient(
  525. to right,
  526. rgba(55, 135, 254, 0.08),
  527. rgba(4, 184, 255, 0.08),
  528. rgba(60, 161, 237, 0.08)
  529. );
  530. background-size: auto 100%;
  531. background-position: right;
  532. background-repeat: no-repeat;
  533. }
  534. .datacard1 {
  535. width: 100%;
  536. margin: 1%;
  537. float: left;
  538. height: 100rpx;
  539. text-align: center;
  540. border-radius: 10px;
  541. background: linear-gradient(
  542. to right,
  543. rgba(55, 135, 254, 0.08),
  544. rgba(4, 184, 255, 0.08),
  545. rgba(60, 161, 237, 0.08)
  546. );
  547. }
  548. </style>