dataTable.vue 13 KB

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