dataTable.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <hc-sys navBarUi='data-table-nav-bar'>
  3. <template #navBar>
  4. <hc-nav-back-bar ui='data-table-nav-bar' :title="treeNode.title"/>
  5. </template>
  6. <uni-collapse class="mb-4" v-model="appUserValue" v-if="appUserList.length">
  7. <uni-collapse-item title="填过数据的用户" >
  8. <view class="hc-table-avatar-content">
  9. <hc-img v-for="item in appUserList" class="avatar-img" :src="item.avatar??avatarPng" :width="35" :height="35"/>
  10. </view>
  11. </uni-collapse-item>
  12. </uni-collapse>
  13. <!--表单列表-->
  14. <template v-if="listItemData.length > 0">
  15. <uni-card v-for="(item, index) in listItemData" padding="0">
  16. <template v-slot:title>
  17. <view class="card-slot-title">{{item.nodeName}}</view>
  18. </template>
  19. <view slot="actions" class="card-actions">
  20. <template v-if="item.isBussShow !== 2">
  21. <view class="card-actions-item border" style="color: #EE5B20" @click="toEditTable(item, index)">
  22. <text class="i-ri-edit-2-fill icon"/>
  23. <text class="card-actions-item-text">填写</text>
  24. </view>
  25. </template>
  26. <template v-if="(item.isCopeTab === 2 || item.isCopeTab === 3) && item.isBussShow !== 2">
  27. <view class="card-actions-item" style="color: #f56c6c" @click="toDelClick(item)">
  28. <text class="i-ri-delete-bin-2-fill icon"/>
  29. <text class="card-actions-item-text">删除</text>
  30. </view>
  31. </template>
  32. <template v-if="item.isLinkTable !== 1">
  33. <view class="card-actions-item" style="color: #4095e5" @click="toCopyClick(item)">
  34. <text class="i-ri-file-copy-2-fill icon"/>
  35. <text class="card-actions-item-text">复制</text>
  36. </view>
  37. </template>
  38. <template v-if="item.isBussShow === 1">
  39. <view class="card-actions-item" style="color: #999999" @click="toShowHideClick(item)">
  40. <text class="i-ri-eye-off-fill icon"/>
  41. <text class="card-actions-item-text">隐藏</text>
  42. </view>
  43. </template>
  44. <template v-if="item.isBussShow !== 1">
  45. <view class="card-actions-item" style="color: #544e80" @click="toShowHideClick(item)">
  46. <text class="i-ri-eye-fill icon"/>
  47. <text class="card-actions-item-text">显示</text>
  48. </view>
  49. </template>
  50. </view>
  51. </uni-card>
  52. </template>
  53. <view v-else class="uni-pt-16" style="text-align: center;">暂无表单</view>
  54. <!--底部操作栏-->
  55. <HcTabbarBlock :height="77"/>
  56. <hc-tabbars>
  57. <view class="hc-data-table-tabbar">
  58. <view class="item"
  59. :style="nodeStatus !== '3' && nodeStatus !== '1' ? 'color: #E99D43;' : 'color: #999999;'"
  60. @click="toReportPage"
  61. >
  62. <view class="item-icon">
  63. <text class="i-ri-send-plane-fill"/>
  64. </view>
  65. <view class="item-name">上报</view>
  66. </view>
  67. <view class="item" :style="nodeStatus === '1' ? 'color: #999999;' : ''" @click="bussPdfsClick">
  68. <view class="item-icon">
  69. <text class="i-ri-eye-fill"/>
  70. </view>
  71. <view class="item-name">预览</view>
  72. </view>
  73. <view class="item" :style="nodeStatus !== '3' ? 'color: #999999;' : ''" @click="abolishOneClick">
  74. <view class="item-icon">
  75. <text class="i-ri-delete-bin-5-line"/>
  76. </view>
  77. <view class="item-name">废除</view>
  78. </view>
  79. </view>
  80. </hc-tabbars>
  81. </hc-sys>
  82. </template>
  83. <script setup>
  84. import {ref} from "vue";
  85. import {onLoad, onShow} from '@dcloudio/uni-app'
  86. import {useAppStore} from "@/store";
  87. import wbsApi from '~api/data-fill/wbs';
  88. import {getArrValue} from "js-fast-way";
  89. import avatarPng from "@/static/image/avatar.png";
  90. import {errorToast, successToast, toPdfPreview} from "@/utils/tools";
  91. import { eVisaTaskCheck } from '~api/other/index'
  92. import api from '~api/api';
  93. const store = useAppStore()
  94. const isNodes = ref(false)
  95. //初始变量
  96. const contractInfo = ref(store.contractInfo);
  97. const projectId = ref(store.projectId);
  98. const contractId = ref(store.contractId);
  99. const treeNode = ref({})
  100. const appUserValue = ref(['0'])
  101. onLoad((option) => {
  102. if (option.node) {
  103. treeNode.value = JSON.parse(decodeURIComponent(option.node));
  104. getTableDataAll();
  105. }
  106. })
  107. onShow(() => {
  108. if (isNodes.value) {
  109. getTableDataAll()
  110. }
  111. })
  112. //获取相关数据
  113. const getTableDataAll = () => {
  114. searchNodeAllTable()
  115. queryNodeStatus()
  116. }
  117. //获取列表数据
  118. const listItemData = ref([])
  119. const appUserList = ref([])
  120. const searchNodeAllTable = async () => {
  121. uni.showLoading({title: '加载中...', mask: true});
  122. const info = treeNode.value
  123. const { data } = await wbsApi.searchNodeAllTable({
  124. projectId: projectId.value,
  125. contractId: contractId.value,
  126. primaryKeyId: info['primaryKeyId'],
  127. type: contractInfo.value?.contractType ?? '',
  128. })
  129. const res = getArrValue(data)
  130. listItemData.value = res
  131. //获取用户列表
  132. const userMap = new Map();
  133. res.forEach((item) => {
  134. const userList = getArrValue(item?.appUserList)
  135. userList.forEach(user => {
  136. userMap.set(user.id,user);
  137. })
  138. })
  139. appUserList.value = [...userMap.values()]
  140. isNodes.value = true
  141. uni.hideLoading();
  142. }
  143. //当前节点状态, 1 未填报,2待上报,3已上报
  144. const nodeStatus = ref('1');
  145. const queryNodeStatus = async () => {
  146. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  147. let url = `blade-business/informationWriteQuery/${type === 1?'queryNodeStatus': 'queryNodeStatus-jl'}`;
  148. //查询节点状态
  149. const { error, code, data } = await api.post({
  150. url: url,
  151. params: {
  152. primaryKeyId: info['primaryKeyId'] ?? '',
  153. classify: type,
  154. }
  155. })
  156. if (!error && code === 200) {
  157. nodeStatus.value = data ?? '1'
  158. } else {
  159. nodeStatus.value = '1'
  160. }
  161. }
  162. //填写表单
  163. const toEditTable = (item) => {
  164. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  165. if(!pkeyId){
  166. errorToast('pkeyId为空');
  167. return
  168. } else if (item.isBussShow === 2) {
  169. errorToast('此表单当前状态不可填写');
  170. return
  171. }
  172. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  173. uni.navigateTo({
  174. url: '/pages/data-fill/editTable?node=' + encodeURIComponent(JSON.stringify({
  175. projectId: projectId.value,
  176. contractId: contractId.value,
  177. status: nodeStatus.value,
  178. treeId: info['primaryKeyId'],
  179. pkeyId: pkeyId,
  180. classify: type,
  181. title: item.nodeName,
  182. isBussShow: item.isBussShow,
  183. isTabPdf: item.isTabPdf,
  184. pdfUrl: item.pdfUrl,
  185. tabFileType: item.tabFileType,
  186. }))
  187. });
  188. }
  189. //删除本表
  190. const toDelClick = async (item) => {
  191. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  192. const type = Number(contractInfo.value?.contractType ?? '')
  193. if(!pkeyId){
  194. errorToast('pkeyId为空');
  195. return
  196. } else if(nodeStatus.value === '3'){
  197. errorToast('已上报的资料,不允许删除');
  198. return
  199. }
  200. uni.showLoading({title: '删除中...', mask: true});
  201. const { error, code, msg } = await wbsApi.removeBussTabInfo({
  202. pkeyid: pkeyId,
  203. classify: type,
  204. })
  205. uni.hideLoading();
  206. if (!error && code === 200) {
  207. getTableDataAll();
  208. successToast('删除成功');
  209. } else {
  210. errorToast('删除失败:' + msg);
  211. }
  212. }
  213. //复制本表
  214. const toCopyClick = async (item) => {
  215. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  216. if(nodeStatus.value === '3'){
  217. errorToast('已上报的资料,不允许复制');
  218. return
  219. } else if(!pkeyId){
  220. errorToast('pkeyId为空');
  221. return
  222. }
  223. uni.showLoading({title: '复制中...', mask: true});
  224. const { error, code, msg } = await wbsApi.copeBussTab({
  225. pkeyId: pkeyId,
  226. })
  227. uni.hideLoading();
  228. if (!error && code === 200) {
  229. getTableDataAll();
  230. successToast('复制成功');
  231. } else {
  232. errorToast('复制失败:' + msg);
  233. }
  234. }
  235. //隐藏本表
  236. const toShowHideClick = async ({ pkeyId, isBussShow }) => {
  237. const pkey_id = pkeyId ? pkeyId + '': ''
  238. if(!pkey_id){
  239. errorToast('pkeyId为空');
  240. return
  241. } else if(nodeStatus.value === '3'){
  242. errorToast('已上报的资料,不允许隐藏或显示');
  243. return
  244. }
  245. uni.showLoading({title: '操作请求中...', mask: true});
  246. const bussShow = isBussShow === 2 ? 1 : 2 //状态(1显示 2隐藏)
  247. const { error, code, msg } = await wbsApi.showBussTab({
  248. pkeyId: pkey_id,
  249. status: bussShow,
  250. })
  251. uni.hideLoading();
  252. if (!error && code === 200) {
  253. getTableDataAll();
  254. successToast('操作成功');
  255. } else {
  256. errorToast('操作失败:' + msg);
  257. }
  258. }
  259. //上报
  260. const toReportPage = async () => {
  261. if(nodeStatus.value === '3'){
  262. errorToast('已上报,无法重复上报');
  263. return
  264. } else if(nodeStatus.value === '1'){
  265. errorToast('请填写保存后再进行上报');
  266. return
  267. }
  268. const rows = listItemData.value
  269. if (rows.length <= 0) {
  270. errorToast('暂无相关数据');
  271. return
  272. }
  273. uni.showLoading({title: '准备相关的数据中...', mask: true});
  274. const {contractIdRelation, primaryKeyId } = treeNode.value;
  275. const type = Number(contractInfo.value?.contractType ?? '')
  276. const { error, code, msg, data } = await eVisaTaskCheck({
  277. projectId: projectId.value,
  278. contractId: type === 2 ? contractIdRelation : contractId.value,
  279. })
  280. //处理数据
  281. if (!error && code === 200 && data === true) {
  282. let newArr = []
  283. for (let i = 0; i < rows.length; i++) {
  284. newArr.push(rows[i]['isTypePrivatePid'])
  285. }
  286. //请求文件题名
  287. const { data } = await wbsApi.queryDocumentTitle({
  288. primaryKeyId: primaryKeyId,
  289. classify: type,
  290. })
  291. uni.hideLoading();
  292. //路由跳转
  293. uni.navigateTo({
  294. url: '/pages/report/report',
  295. events:{
  296. finish: function(data) {
  297. getTableDataAll();
  298. }
  299. },
  300. success: function(res){
  301. res.eventChannel.emit('reportProps', {
  302. type: "wbs",
  303. ids: primaryKeyId,
  304. taskName: data ?? '',
  305. typeData: newArr,
  306. projectId: projectId.value,
  307. contractId: type === 2 ? contractIdRelation : contractId.value,
  308. url: 'informationWriteQuery/taskOne',
  309. addition: {
  310. classify: type,
  311. contractIdRelation: contractIdRelation,
  312. },
  313. })
  314. }
  315. });
  316. } else {
  317. uni.hideLoading();
  318. errorToast(msg);
  319. }
  320. }
  321. //预览
  322. const bussPdfsClick = async () => {
  323. if(nodeStatus.value === '1'){
  324. errorToast('请先填报后再进行预览');
  325. return
  326. }
  327. uni.showLoading({title: '获取数据中...', mask: true});
  328. const {contractIdRelation, primaryKeyId } = treeNode.value;
  329. const type = Number(contractInfo.value?.contractType ?? '')
  330. const { error, code, msg, data } = await wbsApi.getBussPdfs({
  331. nodeId: primaryKeyId ?? '',
  332. classify: type,
  333. projectId: projectId.value,
  334. contractId: type === 2 ? contractIdRelation : contractId.value,
  335. })
  336. uni.hideLoading();
  337. if (!error && code === 200) {
  338. toPdfPreview(data)
  339. } else {
  340. errorToast('获取PDF失败:' + msg);
  341. }
  342. }
  343. //废除 = 客户端中的撤回上报流程
  344. const abolishOneClick = () => {
  345. if(nodeStatus.value !== '3'){
  346. errorToast('只有上报后才能废除上报');
  347. return
  348. }
  349. uni.showModal({
  350. title: '废除上报',
  351. content: '请谨慎考虑后,是否确定废除',
  352. success: (res) => {
  353. if (res.confirm) {
  354. abolishOneSave()
  355. }
  356. }
  357. });
  358. }
  359. //撤回上报的请求
  360. const abolishOneSave = async () => {
  361. uni.showLoading({title: '操作请求中...', mask: true});
  362. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  363. const { error, code, msg } = await wbsApi.abolishOne({
  364. primaryKeyId: info['primaryKeyId'],
  365. classify: type,
  366. })
  367. uni.hideLoading();
  368. if (!error && code === 200) {
  369. getTableDataAll();
  370. successToast('废除成功');
  371. } else {
  372. errorToast('废除失败:' + msg);
  373. }
  374. }
  375. </script>
  376. <style lang="scss" scoped>
  377. page {
  378. background: #FAFBFE;
  379. }
  380. @import "@/style/data-fill/data-table.scss";
  381. </style>
  382. <style lang="scss">
  383. page {
  384. height: auto;
  385. }
  386. </style>