dataTable.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. const info = treeNode.value
  122. const { data } = await wbsApi.searchNodeAllTable({
  123. projectId: projectId.value,
  124. contractId: contractId.value,
  125. primaryKeyId: info['primaryKeyId'],
  126. type: contractInfo.value?.contractType ?? '',
  127. })
  128. const res = getArrValue(data)
  129. listItemData.value = res
  130. //获取用户列表
  131. const userMap = new Map();
  132. res.forEach((item) => {
  133. const userList = getArrValue(item?.appUserList)
  134. userList.forEach(user => {
  135. userMap.set(user.id,user);
  136. })
  137. })
  138. appUserList.value = [...userMap.values()]
  139. isNodes.value = true
  140. }
  141. //当前节点状态, 1 未填报,2待上报,3已上报
  142. const nodeStatus = ref('1');
  143. const queryNodeStatus = async () => {
  144. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  145. let url = `blade-business/informationWriteQuery/${type === 1?'queryNodeStatus': 'queryNodeStatus-jl'}`;
  146. //查询节点状态
  147. const { error, code, data } = await api.post({
  148. url: url,
  149. params: {
  150. primaryKeyId: info['primaryKeyId'] ?? '',
  151. classify: type,
  152. }
  153. })
  154. if (!error && code === 200) {
  155. nodeStatus.value = data ?? '1'
  156. } else {
  157. nodeStatus.value = '1'
  158. }
  159. }
  160. //填写表单
  161. const toEditTable = (item) => {
  162. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  163. if(!pkeyId){
  164. errorToast('pkeyId为空');
  165. return
  166. } else if (item.isBussShow === 2) {
  167. errorToast('此表单当前状态不可填写');
  168. return
  169. }
  170. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  171. uni.navigateTo({
  172. url: '/pages/data-fill/editTable?node=' + encodeURIComponent(JSON.stringify({
  173. projectId: projectId.value,
  174. contractId: contractId.value,
  175. status: nodeStatus.value,
  176. treeId: info['primaryKeyId'],
  177. pkeyId: pkeyId,
  178. classify: type,
  179. title: item.nodeName,
  180. isBussShow: item.isBussShow,
  181. isTabPdf: item.isTabPdf,
  182. pdfUrl: item.pdfUrl,
  183. tabFileType: item.tabFileType,
  184. }))
  185. });
  186. }
  187. //删除本表
  188. const toDelClick = async (item) => {
  189. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  190. const type = Number(contractInfo.value?.contractType ?? '')
  191. if(!pkeyId){
  192. errorToast('pkeyId为空');
  193. return
  194. } else if(nodeStatus.value === '3'){
  195. errorToast('已上报的资料,不允许删除');
  196. return
  197. }
  198. uni.showLoading({title: '删除中...', mask: true});
  199. const { error, code, msg } = await wbsApi.removeBussTabInfo({
  200. pkeyid: pkeyId,
  201. classify: type,
  202. })
  203. uni.hideLoading();
  204. if (!error && code === 200) {
  205. getTableDataAll();
  206. successToast('删除成功');
  207. } else {
  208. errorToast('删除失败:' + msg);
  209. }
  210. }
  211. //复制本表
  212. const toCopyClick = async (item) => {
  213. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  214. if(nodeStatus.value === '3'){
  215. errorToast('已上报的资料,不允许复制');
  216. return
  217. } else if(!pkeyId){
  218. errorToast('pkeyId为空');
  219. return
  220. }
  221. uni.showLoading({title: '复制中...', mask: true});
  222. const { error, code, msg } = await wbsApi.copeBussTab({
  223. pkeyId: pkeyId,
  224. })
  225. uni.hideLoading();
  226. if (!error && code === 200) {
  227. getTableDataAll();
  228. successToast('复制成功');
  229. } else {
  230. errorToast('复制失败:' + msg);
  231. }
  232. }
  233. //隐藏本表
  234. const toShowHideClick = async ({ pkeyId, isBussShow }) => {
  235. const pkey_id = pkeyId ? pkeyId + '': ''
  236. if(!pkey_id){
  237. errorToast('pkeyId为空');
  238. return
  239. } else if(nodeStatus.value === '3'){
  240. errorToast('已上报的资料,不允许隐藏或显示');
  241. return
  242. }
  243. uni.showLoading({title: '操作请求中...', mask: true});
  244. const bussShow = isBussShow === 2 ? 1 : 2 //状态(1显示 2隐藏)
  245. const { error, code, msg } = await wbsApi.showBussTab({
  246. pkeyId: pkey_id,
  247. status: bussShow,
  248. })
  249. uni.hideLoading();
  250. if (!error && code === 200) {
  251. getTableDataAll();
  252. successToast('操作成功');
  253. } else {
  254. errorToast('操作失败:' + msg);
  255. }
  256. }
  257. //上报
  258. const toReportPage = async () => {
  259. if(nodeStatus.value === '3'){
  260. errorToast('已上报,无法重复上报');
  261. return
  262. } else if(nodeStatus.value === '1'){
  263. errorToast('请填写保存后再进行上报');
  264. return
  265. }
  266. const rows = listItemData.value
  267. if (rows.length <= 0) {
  268. errorToast('暂无相关数据');
  269. return
  270. }
  271. uni.showLoading({title: '准备相关的数据中...', mask: true});
  272. const {contractIdRelation, primaryKeyId } = treeNode.value;
  273. const type = Number(contractInfo.value?.contractType ?? '')
  274. const { error, code, msg, data } = await eVisaTaskCheck({
  275. projectId: projectId.value,
  276. contractId: type === 2 ? contractIdRelation : contractId.value,
  277. })
  278. //处理数据
  279. if (!error && code === 200 && data === true) {
  280. let newArr = []
  281. for (let i = 0; i < rows.length; i++) {
  282. newArr.push(rows[i]['isTypePrivatePid'])
  283. }
  284. //请求文件题名
  285. const { data } = await wbsApi.queryDocumentTitle({
  286. primaryKeyId: primaryKeyId,
  287. classify: type,
  288. })
  289. uni.hideLoading();
  290. //路由跳转
  291. uni.navigateTo({
  292. url: '/pages/report/report',
  293. events:{
  294. finish: function(data) {
  295. getTableDataAll();
  296. }
  297. },
  298. success: function(res){
  299. res.eventChannel.emit('reportProps', {
  300. type: "wbs",
  301. ids: primaryKeyId,
  302. taskName: data ?? '',
  303. typeData: newArr,
  304. projectId: projectId.value,
  305. contractId: type === 2 ? contractIdRelation : contractId.value,
  306. url: 'informationWriteQuery/taskOne',
  307. addition: {
  308. classify: type,
  309. contractIdRelation: contractIdRelation,
  310. },
  311. })
  312. }
  313. });
  314. } else {
  315. uni.hideLoading();
  316. errorToast(msg);
  317. }
  318. }
  319. //预览
  320. const bussPdfsClick = async () => {
  321. if(nodeStatus.value === '1'){
  322. errorToast('请先填报后再进行预览');
  323. return
  324. }
  325. uni.showLoading({title: '获取数据中...', mask: true});
  326. const {contractIdRelation, primaryKeyId } = treeNode.value;
  327. const type = Number(contractInfo.value?.contractType ?? '')
  328. const { error, code, msg, data } = await wbsApi.getBussPdfs({
  329. nodeId: primaryKeyId ?? '',
  330. classify: type,
  331. projectId: projectId.value,
  332. contractId: type === 2 ? contractIdRelation : contractId.value,
  333. })
  334. uni.hideLoading();
  335. if (!error && code === 200) {
  336. toPdfPreview(data)
  337. } else {
  338. errorToast('获取PDF失败:' + msg);
  339. }
  340. }
  341. //废除 = 客户端中的撤回上报流程
  342. const abolishOneClick = () => {
  343. if(nodeStatus.value !== '3'){
  344. errorToast('只有上报后才能废除上报');
  345. return
  346. }
  347. uni.showModal({
  348. title: '废除上报',
  349. content: '请谨慎考虑后,是否确定废除',
  350. success: (res) => {
  351. if (res.confirm) {
  352. abolishOneSave()
  353. }
  354. }
  355. });
  356. }
  357. //撤回上报的请求
  358. const abolishOneSave = async () => {
  359. uni.showLoading({title: '操作请求中...', mask: true});
  360. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  361. const { error, code, msg } = await wbsApi.abolishOne({
  362. primaryKeyId: info['primaryKeyId'],
  363. classify: type,
  364. })
  365. uni.hideLoading();
  366. if (!error && code === 200) {
  367. getTableDataAll();
  368. successToast('废除成功');
  369. } else {
  370. errorToast('废除失败:' + msg);
  371. }
  372. }
  373. </script>
  374. <style lang="scss" scoped>
  375. page {
  376. background: #FAFBFE;
  377. }
  378. @import "@/style/data-fill/data-table.scss";
  379. </style>
  380. <style lang="scss">
  381. page {
  382. height: auto;
  383. }
  384. </style>