commission.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <template>
  2. <hc-body split :project-nmae="projectInfo?.projectName">
  3. <template #tree>
  4. <TestTree
  5. :auto-expand-keys="treeAutoExpandKeys" :project-id="projectId" :tenant-id="userInfo?.tenant_id"
  6. :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2" :entrust="1"
  7. @node-tap="wbsElTreeClick"
  8. />
  9. </template>
  10. <hc-new-card w-to="1919">
  11. <template #headerToSearch>
  12. <div class="w-50">
  13. <el-select v-model="searchForm.contractId" placeholder="选择合同段" filterable block>
  14. <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
  15. </el-select>
  16. </div>
  17. <div class="ml-2 w-40">
  18. <el-select v-model="searchForm.status" placeholder="委托单状态" filterable clearable block>
  19. <el-option v-for="item in entrustStatus" :key="item.value" :label="item.label" :value="item.value" />
  20. </el-select>
  21. </div>
  22. <div class="ml-2 w-350px">
  23. <hc-search-input v-model="searchForm.entrustName" @search="searchClick" />
  24. </div>
  25. </template>
  26. <template #extraToHeader>
  27. <hc-tooltip keys="tentative_detect_commission_add">
  28. <el-button hc-btn type="primary" @click="addFormData">
  29. <hc-icon name="add-circle" />
  30. <span>新增</span>
  31. </el-button>
  32. </hc-tooltip>
  33. <el-button :disabled="tableCheckedKeys.length <= 0" :loading="signLoading" hc-btn type="primary" @click="resignClick">re-sign</el-button>
  34. <hc-tooltip keys="tentative_detect_commission_repeal">
  35. <el-button hc-btn type="danger" :disabled="tableCheckedKeys.length <= 0" @click="repealFormData">
  36. <hc-icon name="arrow-go-back" />
  37. <span>废除</span>
  38. </el-button>
  39. </hc-tooltip>
  40. <hc-tooltip keys="tentative_detect_commission_del">
  41. <el-button v-del-com:[delModalClick] :disabled="tableCheckedKeys.length <= 0" hc-btn type="danger">
  42. <hc-icon name="delete-bin-2" />
  43. <span>删除</span>
  44. </el-button>
  45. </hc-tooltip>
  46. <hc-tooltip keys="tentative_material_commission_prin">
  47. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn color="#567722" @click="batchPrinting">
  48. <hc-icon name="printer" />
  49. <span>批量打印</span>
  50. </el-button>
  51. </hc-tooltip>
  52. <hc-tooltip keys="tentative_detect_commission_report">
  53. <el-button :disabled="tableCheckedKeys.length <= 0" class="text-white" hc-btn color="#FF976A" @click="reportClick">
  54. <HcIcon name="send-plane-2" />
  55. <span>上报</span>
  56. </el-button>
  57. </hc-tooltip>
  58. <hc-tooltip keys="tentative_material_commission_null">
  59. <el-button hc-btn color="#567722" @click="printerNull">
  60. <hc-icon name="printer" />
  61. <span>打印空表</span>
  62. </el-button>
  63. </hc-tooltip>
  64. </template>
  65. <hc-table
  66. :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check
  67. :index-style="{ width: 60 }" :check-style="{ width: 29 }" @selection-change="tableSelection"
  68. >
  69. <template #status="{ row }">
  70. <el-tag v-if="row.status === 1" type="info" effect="dark">未上报</el-tag>
  71. <el-tag v-if="row.status === 2" type="warning" effect="dark">已上报-待审批</el-tag>
  72. <el-tag v-if="row.status === 3" type="primary" effect="dark">待试验</el-tag>
  73. <el-tag v-if="row.status === 4" type="success" effect="dark">委托完成</el-tag>
  74. </template>
  75. <template #action="{ row }">
  76. <hc-tooltip keys="tentative_material_commission_edit">
  77. <el-link v-if="row.status === 1" v-loading="row.rowLoad" type="primary" @click="rowEdit(row)">修改</el-link>
  78. <el-link v-else type="success" @click="rowView(row)">查看</el-link>
  79. </hc-tooltip>
  80. <hc-tooltip keys="tentative_material_commission_fill">
  81. <el-link v-if="row.status === 4" type="info" disabled>创建成功</el-link>
  82. <el-link v-else-if="!isNullES(row.testId)" type="danger" :disabled="row.status !== 3" @click="rowFillReports(row)">填写报告</el-link>
  83. <el-link v-else type="danger" :disabled="row.status !== 3" @click="rowReports(row)">创建报告</el-link>
  84. </hc-tooltip>
  85. </template>
  86. </hc-table>
  87. <template #action>
  88. <hc-pages :pages="searchForm" @change="pageChange" />
  89. </template>
  90. </hc-new-card>
  91. <!-- 新增委托 -->
  92. <hc-new-dialog v-model="delegateModal" ui="hc-delegate-html-modal" is-footer-center is-table :title="`${editHtmlId ? '修改' : '新增'}委托`" widths="60rem" @close="delegateModalClose">
  93. <div class="hc-delegate-contract hc-flex h-40px">
  94. <el-select v-model="delegateContractId" placeholder="请先选择合同段" filterable class="w-400px" @change="delegateContractChange">
  95. <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
  96. </el-select>
  97. </div>
  98. <div class="hc-delegate-html" :class="delegateContractId ? 'is-show' : ''">
  99. <hc-table-form ref="htmlRef" :pkey="nodeErTreeId" :form="delegateHtmlForm" :html="delegateHtml" :loading="delegateHtmlLoading" @render="delegateHtmlRender" />
  100. </div>
  101. <template #footer>
  102. <el-button @click="delegateModalClose">取消</el-button>
  103. <el-button hc-btn type="warning" @click="linkSamplingModal = true">关联取样材料</el-button>
  104. <el-button v-if="editHtmlId" hc-btn type="primary" @click="creatingDelegate">保存</el-button>
  105. <el-button v-else hc-btn type="primary" :loading="creatingDelegateLoad" @click="creatingDelegate">创建</el-button>
  106. </template>
  107. </hc-new-dialog>
  108. <!-- 关联取样材料 -->
  109. <SamplingPage v-model="linkSamplingModal" v-model:id="delegateHtmlForm.sampleId" :cid="searchForm.contractId" @change="linkSamplingChange" />
  110. <!-- 创建报告 -->
  111. <hc-new-dialog v-model="rowActionModal" is-footer-center title="创建报告" widths="40rem" @close="rowActionModalClose">
  112. <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="top" label-width="auto">
  113. <el-row :gutter="20">
  114. <el-col :span="12">
  115. <el-form-item label="委托单位:">
  116. <el-input v-model="formModel.entrustInfo" placeholder="委托单位" disabled />
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="12">
  120. <el-form-item label="委托单位名称:">
  121. <el-input v-model="formModel.entrustName" placeholder="委托单位名称" disabled />
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="12">
  125. <el-form-item label="取样名称:">
  126. <el-input v-model="formModel.materialName" placeholder="取样名称" disabled />
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="12">
  130. <el-form-item label="取样数量:">
  131. <el-input v-model="formModel.materialCount" placeholder="取样数量" disabled />
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="12">
  135. <el-form-item label="样品编号:">
  136. <el-input v-model="formModel.entrustNo" placeholder="样品编号" disabled />
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="12">
  140. <el-form-item label="试验数量:" prop="expCount">
  141. <el-input v-model="formModel.expCount" placeholder="试验数量" />
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="12">
  145. <el-form-item label="规格型号:">
  146. <el-input v-model="formModel.specificationModel" placeholder="规格型号" disabled />
  147. </el-form-item>
  148. </el-col>
  149. <el-col :span="12">
  150. <el-form-item label="计算单位:">
  151. <el-input v-model="formModel.calculationUnit" placeholder="计算单位" disabled />
  152. </el-form-item>
  153. </el-col>
  154. </el-row>
  155. </el-form>
  156. <template #footer>
  157. <el-button @click="rowActionModalClose">取消</el-button>
  158. <el-button hc-btn type="primary" :loading="rowActionLoading" @click="rowActionSave">创建</el-button>
  159. </template>
  160. </hc-new-dialog>
  161. <!-- 上报审批 -->
  162. <hc-report-modal
  163. :show="showReportModal"
  164. :classify-type="classifyType"
  165. :addition="reportAddition"
  166. :contract-id="contractId"
  167. :ids="reportIds"
  168. :project-id="projectId"
  169. :task-name="reportTaskName"
  170. :trial-self-inspection-record-id="2"
  171. title="上报审批" type="wbs"
  172. url="informationWriteQuery/batchTask"
  173. @finish="showReportFinish"
  174. @hide="hideReport"
  175. />
  176. </hc-body>
  177. <!-- 一键重签弹窗 -->
  178. <hc-new-dialog v-model="resignModal" title="一键重签" widths="38rem" :loading="signLoading" @close="cancelresign" @save="signClick">
  179. <div>
  180. 是否重新生成pdf:
  181. <el-radio-group v-model="resignModalRadio">
  182. <el-radio :value="2">否</el-radio>
  183. <el-radio :value="1">是</el-radio>
  184. </el-radio-group>
  185. </div>
  186. </hc-new-dialog>
  187. </template>
  188. <script setup>
  189. import { onActivated, onMounted, ref } from 'vue'
  190. import { useAppStore } from '~src/store'
  191. import { useRouter } from 'vue-router'
  192. import { getStoreValue, setStoreValue } from '~src/utils/storage'
  193. import { arrToId, deepClone, formValidate, getArrValue, getObjVal, getObjValue, isNullES, isString } from 'js-fast-way'
  194. import { toPdfPage } from '~uti/btn-auth'
  195. import { getDictionaryData } from '~uti/tools'
  196. import { getErtractInfo } from '~api/other'
  197. import mainApi from '~api/tentative/detect/commission'
  198. import samplingApi from '~api/tentative/material/sampling'
  199. import TestTree from '~src/views/tentative/material/components/TestTree.vue'
  200. import SamplingPage from './commission/sampling.vue'
  201. import wbsApi from '~api/data-fill/wbs'
  202. import dataApi from '~api/basic/code'
  203. //变量
  204. const router = useRouter()
  205. const useAppState = useAppStore()
  206. const userInfo = ref(useAppState.getUserInfo)
  207. const projectId = ref(useAppState.getProjectId)
  208. const contractId = ref(useAppState.getContractId)
  209. const projectInfo = ref(useAppState.getProjectInfo)
  210. const contractInfo = ref(useAppState.getContractInfo)
  211. //渲染完成
  212. onActivated(() => {
  213. getContractData()
  214. getEntrustStatusData()
  215. })
  216. //搜索表单
  217. const searchForm = ref({ entrustName: null, current: 1, size: 20, total: 0 })
  218. //自动展开缓存
  219. const treeAutoExpandKeys = ref(getStoreValue('testTreeExpandKeys') || [])
  220. //树被点击
  221. const nodeDataInfo = ref({})
  222. const nodeErTreeId = ref('')
  223. const wbsElTreeClick = ({ data, keys }) => {
  224. nodeDataInfo.value = data
  225. //nodeErTreeId.value = data['erTreeId'] || ''
  226. //缓存自动展开
  227. treeAutoExpandKeys.value = keys
  228. setStoreValue('testTreeExpandKeys', keys)
  229. searchForm.value.nodeId = data['primaryKeyId'] || ''
  230. //获取表格
  231. searchClick()
  232. }
  233. //获取合同段信息
  234. const contractData = ref([])
  235. const getContractData = async () => {
  236. const { data } = await getErtractInfo({
  237. projectId: projectId.value,
  238. contractId: contractId.value,
  239. })
  240. const res = getArrValue(data)
  241. contractData.value = res
  242. if (res.length <= 0) return
  243. let cid
  244. for (let i = 0; i < res.length; i++) {
  245. if (contractId.value == res[i].id) {
  246. cid = res[i].id
  247. }
  248. }
  249. searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
  250. }
  251. //获取状态
  252. const entrustStatus = ref([])
  253. const getEntrustStatusData = async () => {
  254. entrustStatus.value = await getDictionaryData('entrust_status', true)
  255. }
  256. //搜索
  257. const searchClick = () => {
  258. searchForm.value.current = 1
  259. getTableData()
  260. }
  261. //分页被点击
  262. const pageChange = ({ current, size }) => {
  263. searchForm.value.current = current
  264. searchForm.value.size = size
  265. getTableData()
  266. }
  267. //表格数据
  268. const tableData = ref([])
  269. const tableColumn = ref([
  270. { key: 'entrustInfo', name: '委托单位' },
  271. { key: 'entrustNo', name: '委托单编号' },
  272. { key: 'entrustName', name: '委托单名称' },
  273. { key: 'materialName', name: '关联材料名称' },
  274. { key: 'status', name: '委托单状态', width: 120, align: 'center' },
  275. { key: 'action', name: '操作', width: 120, align: 'center', fixed: 'right' },
  276. ])
  277. //获取数据
  278. const tableLoading = ref(false)
  279. const getTableData = async () => {
  280. tableLoading.value = true
  281. const { error, code, data } = await mainApi.page(searchForm.value)
  282. //处理数据
  283. tableLoading.value = false
  284. if (!error && code === 200) {
  285. tableData.value = getArrValue(data['records'])
  286. searchForm.value.total = data.total || 0
  287. } else {
  288. tableData.value = []
  289. searchForm.value.total = 0
  290. }
  291. }
  292. //多选
  293. const tableCheckedKeys = ref([])
  294. const tableSelection = (rows) => {
  295. tableCheckedKeys.value = rows
  296. }
  297. //删除
  298. const delModalClick = async (_, resolve) => {
  299. const rows = tableCheckedKeys.value
  300. if (rows.length <= 0) {
  301. window.$message.warning('请先勾选需要删除的数据')
  302. return
  303. }
  304. const { error, code, msg } = await mainApi.remove(arrToId(rows))
  305. resolve()
  306. if (!error && code === 200) {
  307. window.$message.success('删除成功')
  308. getTableData().then()
  309. } else {
  310. window.$message.error(msg || '删除失败')
  311. }
  312. }
  313. //委托单变量
  314. const htmlRef = ref(null)
  315. const delegateHtml = ref('')
  316. const delegateHtmlForm = ref({})
  317. const delegateHtmlLoading = ref(false)
  318. const delegateContractId = ref(null)
  319. //新增
  320. const delegateModal = ref(false)
  321. const addFormData = () => {
  322. if ( !searchForm.value.nodeId) {
  323. window.$message.warning('请先选择节点')
  324. return
  325. }
  326. delegateModal.value = true
  327. editHtmlId.value = ''
  328. const { contractId } = deepClone(searchForm.value)
  329. delegateContractId.value = contractId
  330. if (!isNullES(contractId)) {
  331. delegateContractChange()
  332. }
  333. }
  334. //合同段被选择
  335. const delegateContractChange = async () => {
  336. delegateHtmlLoading.value = true
  337. //await getDelegateDataInfo(editHtmlId.value)
  338. await getDelegateExcelHtml()
  339. getMaterialNumber()
  340. delegateHtmlLoading.value = false
  341. }
  342. //获取委托单编号
  343. const backObj = ref({})
  344. const getMaterialNumber = async () => {
  345. const { error, code, data } = await dataApi.getEntrustNumber({
  346. contractId: contractId.value,
  347. pkeyId: searchForm.value.nodeId,
  348. })
  349. //处理数据
  350. if (!error && code === 200) {
  351. backObj.value = getObjVal(data)
  352. let mergedObject = null
  353. // 合并对象并赋值给新对象
  354. if (Object.keys(backObj.value).length > 0 && Object.keys(delegateHtmlForm.value).length > 0) {
  355. mergedObject = { ...backObj.value, ...delegateHtmlForm.value }
  356. } else if (Object.keys(backObj.value).length > 0) {
  357. mergedObject = { ...backObj.value }
  358. } else if (Object.keys(delegateHtmlForm.value).length > 0) {
  359. mergedObject = { ...delegateHtmlForm.value }
  360. } else {
  361. mergedObject = {}
  362. }
  363. // 可以在这里使用 mergedObject.value
  364. delegateHtmlForm.value = mergedObject
  365. } else {
  366. backObj.value = {}
  367. }
  368. }
  369. //获取委托html
  370. const getDelegateExcelHtml = async () => {
  371. const { error, code, msg, data } = await samplingApi.getExcelHtml({
  372. nodeId: searchForm.value.nodeId,
  373. contractId: contractId.value,
  374. })
  375. if (!error && code === 200) {
  376. delegateHtml.value = isString(data) ? data : ''
  377. nodeErTreeId.value = msg === '未知错误' ? null : msg
  378. } else {
  379. delegateHtml.value = ''
  380. window.$message.error(msg || '获取委托信息失败')
  381. }
  382. }
  383. //关联材料选择
  384. const cancelRowData = ref({})
  385. const linkSamplingChange = async ({ id, entrustId }, cancelRow) => {
  386. await getDelegateExcelHtml()
  387. if (!id) {
  388. cancelRowData.value = cancelRow
  389. await getCancelRow( cancelRow)
  390. await getDelegateDataInfo('', cancelRow.entrustId, null)
  391. } else {
  392. await getDelegateDataInfo(id, entrustId, delegateHtmlForm.value)
  393. }
  394. }
  395. //取消关联取样
  396. const getCancelRow = async (cancelRow) => {
  397. const { error, code, msg, data } = await samplingApi.cancelSample({
  398. groupId: cancelRow.entrustId,
  399. sampleId1: cancelRow.id,
  400. pkeyId: nodeErTreeId.value,
  401. contractId: delegateContractId.value,
  402. })
  403. }
  404. //获取委托数据
  405. const getDelegateDataInfo = async (id, entrustId, formData) => {
  406. const { primaryKeyId } = nodeDataInfo.value
  407. const { error, code, msg, data } = await samplingApi.getBussDataInfoTrialEntrust({
  408. id: entrustId,
  409. sampleId: id,
  410. pkeyId: nodeErTreeId.value,
  411. projectId: projectId.value,
  412. contractId: delegateContractId.value,
  413. nodeId: primaryKeyId,
  414. formData: JSON.stringify(formData),
  415. })
  416. if (!error && code === 200) {
  417. delegateHtmlForm.value = getObjValue(data[0])
  418. } else {
  419. delegateHtmlForm.value = {}
  420. window.$message.error(msg || '获取委托信息失败')
  421. }
  422. }
  423. //委托单html渲染完成
  424. const delegateHtmlRender = (form) => {
  425. delegateHtmlForm.value = form
  426. }
  427. //修改
  428. const editHtmlId = ref('')
  429. const rowEdit = async (row) => {
  430. editHtmlId.value = row.id
  431. const { contractId } = deepClone(searchForm.value)
  432. delegateContractId.value = contractId
  433. if (!isNullES(contractId)) {
  434. // delegateContractChange()
  435. row.rowLoad = true
  436. delegateHtmlLoading.value = true
  437. await getDelegateExcelHtml()
  438. await getDelegateDataInfo('', row.id)
  439. row. rowLoad = false
  440. delegateHtmlLoading.value = false
  441. delegateModal.value = true
  442. }
  443. }
  444. //关联取样材料
  445. const linkSamplingModal = ref(false)
  446. //创建委托
  447. const creatingDelegateLoad = ref(false)
  448. const creatingDelegate = async () => {
  449. if (isNullES(delegateHtml.value)) {
  450. window.$message.error('暂无委托单信息')
  451. return
  452. }
  453. const form = delegateHtmlForm.value
  454. if (isNullES(delegateContractId.value)) {
  455. window.$message.warning('请先选择合同段')
  456. return
  457. }
  458. // const { title } = nodeDataInfo.value
  459. // let isCan = (title === '回弹法检测混凝土抗压强度' || title === '路基压实度' || title === '地基承载力' || title === '路基路面弯沉' || title === '锚杆' || title === '喷射混凝土厚度')
  460. // if (isNullES(form.sampleId) && !isCan ) {
  461. // window.$message.warning('请先关联取样材料')
  462. // return
  463. // }
  464. const { nodeType } = nodeDataInfo.value
  465. if (nodeType !== 51 && isNullES(form.sampleId)) {
  466. window.$message.warning('请先关联取样材料')
  467. return
  468. }
  469. //修改时的id
  470. if (!isNullES(editHtmlId.value)) {
  471. form.id = editHtmlId.value
  472. }
  473. //处理数据
  474. const { primaryKeyId } = nodeDataInfo.value
  475. form.contractId = delegateContractId.value
  476. form.nodeErTreeId = nodeErTreeId.value
  477. form.nodeId = primaryKeyId
  478. form.autoIncrementNumber = backObj.value.autoIncrementNumber
  479. form.trialNumber = backObj.value.trialNumber
  480. //发起请求
  481. creatingDelegateLoad.value = true
  482. const { error, code, msg } = await mainApi.htmlSave(form)
  483. creatingDelegateLoad.value = false
  484. if (!error && code === 200) {
  485. window.$message.success('创建成功')
  486. delegateModalClose()
  487. getTableData().then()
  488. } else {
  489. window.$message.error(msg || '创建失败')
  490. }
  491. }
  492. //关闭委托
  493. const delegateModalClose = () => {
  494. delegateModal.value = false
  495. delegateHtmlForm.value = {}
  496. delegateHtml.value = ''
  497. delegateContractId.value = null
  498. delegateHtmlLoading.value = false
  499. }
  500. //查看
  501. const rowView = ({ entrustEPdf, entrustPdf }) => {
  502. if (isNullES(entrustPdf) && isNullES(entrustEPdf)) {
  503. window.$message.warning('暂无PDF数据')
  504. return
  505. }
  506. if (!isNullES(entrustEPdf)) {
  507. toPdfPage(entrustEPdf)
  508. } else if (!isNullES(entrustPdf)) {
  509. toPdfPage(entrustPdf)
  510. }
  511. }
  512. //表单数据
  513. const formRef = ref(null)
  514. const formModel = ref({})
  515. const formRules = {
  516. expCount: {
  517. required: true,
  518. trigger: 'blur',
  519. message: '请填写试验数量',
  520. },
  521. }
  522. //创建报告
  523. const rowActionModal = ref(false)
  524. const creatRow = ref({})
  525. const rowReports = async (row) => {
  526. rowActionModal.value = true
  527. const { data } = await mainApi.detail(row.id)
  528. formModel.value = getObjValue(data)
  529. creatRow.value = row
  530. }
  531. //提交保存
  532. const rowActionLoading = ref(false)
  533. const rowActionSave = async () => {
  534. const isForm = await formValidate(formRef.value)
  535. if (!isForm) return
  536. rowActionLoading.value = true
  537. const { contractType } = contractInfo.value
  538. const { expCount } = formModel.value
  539. const { primaryKeyId } = nodeDataInfo.value
  540. setStoreValue('testTreeItem', nodeDataInfo.value)
  541. setStoreValue('prenodeDataInfo', nodeDataInfo.value)
  542. const { repealType, sampleStatus, id } = creatRow.value
  543. const { error, code, msg } = await mainApi.update({ id, expCount, repealType, sampleStatus })
  544. if (!error && code === 200) {
  545. window.$message.success('创建成功')
  546. rowActionLoading.value = false
  547. rowActionModalClose()
  548. router.push({
  549. path: '/tentative/detect/test-form',
  550. query: {
  551. nodeId: primaryKeyId || '',
  552. dataType: contractType > 0 ? contractType + '' : '1',
  553. commissionId: id,
  554. cid: searchForm.value?.contractId,
  555. isaddType: true,
  556. },
  557. }).then()
  558. } else {
  559. rowActionLoading.value = false
  560. window.$message.error(msg || '创建失败')
  561. }
  562. }
  563. //关闭弹窗
  564. const rowActionModalClose = () => {
  565. rowActionModal.value = false
  566. formModel.value = {}
  567. }
  568. //填写报告
  569. const rowFillReports = async ({ id, testId }) => {
  570. const { error, code, data, msg } = await mainApi.selfDetail(testId)
  571. if (!error && code === 200) {
  572. const res = getObjValue(data)
  573. setStoreValue('test-form', res)
  574. setStoreValue('testTreeItem', nodeDataInfo.value)
  575. setStoreValue('prenodeDataInfo', nodeDataInfo.value)
  576. router.push({
  577. path: '/tentative/detect/test-form',
  578. query: {
  579. id: testId,
  580. nodeId: res.nodeId,
  581. dataType: res.type,
  582. commissionId: id,
  583. tabTypeKey: 1,
  584. cid: searchForm.value?.contractId,
  585. },
  586. }).then()
  587. } else {
  588. window.$message.error(msg || '操作失败')
  589. }
  590. }
  591. //批量打印
  592. const batchPrinting = () => {
  593. }
  594. //上报
  595. const classifyType = ref('')
  596. const reportIds = ref('')
  597. const reportTaskName = ref('')
  598. const showReportModal = ref(false)
  599. const reportAddition = ref({})
  600. const reportClick = async () => {
  601. const rows = tableCheckedKeys.value
  602. if (rows.length <= 0) {
  603. window.$message.warning('请先勾选一条需要上报的数据')
  604. return
  605. }
  606. //判断状态
  607. const { status, entrustName } = { ...rows[0] }
  608. if (status !== 1) {
  609. window.$message.warning('只能选择未上报的数据进行上报')
  610. return
  611. }
  612. // 委托单上报设置为1
  613. classifyType.value = '1'
  614. //其它数据
  615. // reportIds.value = rows[0].id //数据ID
  616. reportIds.value = arrToId(rows) //数据ID
  617. // reportTaskName.value = entrustName //任务名称
  618. //附加数据
  619. const { contractIdRelation } = nodeDataInfo.value
  620. reportAddition.value = {
  621. taskType: '1', //用来区分委托单
  622. classify: classifyType.value,
  623. contractIdRelation: contractIdRelation,
  624. }
  625. //请求文件题名
  626. const { data } = await wbsApi.queryDocumentTitle({
  627. // primaryKeyId: info['primaryKeyId'],
  628. primaryKeyId: rows[0].id,
  629. classify: '1',
  630. })
  631. reportTaskName.value = isString(data) ? data : ''
  632. //显示任务上报
  633. showReportModal.value = true
  634. }
  635. //上报完成
  636. const showReportFinish = () => {
  637. hideReport()
  638. getTableData()
  639. }
  640. //关闭上报弹窗
  641. const hideReport = () => {
  642. showReportModal.value = false
  643. classifyType.value = ''
  644. reportAddition.value = {}
  645. reportIds.value = ''
  646. reportTaskName.value = ''
  647. }
  648. //打印空表
  649. const printerNull = () => {
  650. }
  651. //废除
  652. const repealFormData = async ()=>{
  653. const rows = tableCheckedKeys.value
  654. if (rows.length <= 0) {
  655. window.$message.warning('请先勾选需要废除的数据')
  656. return
  657. }
  658. //判断是否满足条件
  659. const result = rows.every(({ status, expCount }) => {
  660. return status === 2 && expCount === 0 || status === 2 && expCount === null || status === 3 && expCount === null || status === 3 && expCount === 0
  661. })
  662. if (!result) return window.$message.warning('所选择的数据不能进行废除操作')
  663. const { error, code, msg } = await mainApi.annul({ id:arrToId(rows) })
  664. if (!error && code === 200) {
  665. window.$message.success(msg)
  666. getTableData().then()
  667. } else {
  668. window.$message.error(msg || '删除失败')
  669. }
  670. }
  671. //一键重签
  672. //一键重签
  673. const signLoading = ref(false)
  674. const resignModal = ref(false)
  675. const resignModalRadio = ref(1)
  676. const resignClick = async ()=>{
  677. const rows = tableCheckedKeys.value
  678. if (rows.length <= 0) {
  679. window.$message?.warning('请先勾选已审批的数据')
  680. return
  681. }
  682. resignModal.value = true
  683. }
  684. const signClick = async () => {
  685. const rows = tableCheckedKeys.value
  686. const { primaryKeyId } = nodeDataInfo.value
  687. let objArr = []
  688. rows.forEach((item)=>{
  689. objArr.push({
  690. // taskId:item.taskId || '',
  691. entrustId:item.id,
  692. type:resignModalRadio.value,
  693. nodeId:primaryKeyId,
  694. contractId: contractId.value,
  695. status:item.status,
  696. })
  697. })
  698. //发起请求
  699. signLoading.value = true
  700. const { error, code, msg } = await mainApi.reSigningEntrust(objArr)
  701. //处理数据
  702. signLoading.value = false
  703. if (!error && code === 200) {
  704. window.$message?.success(msg ?? '提交成功,请请耐心等待重签,可继续操作其它的功能。')
  705. getTableData().then()
  706. } else {
  707. window.$message?.error(msg ?? '操作失败')
  708. }
  709. resignModal.value = false
  710. }
  711. const cancelresign = ()=>{
  712. resignModalRadio.value = 0
  713. resignModal.value = false
  714. }
  715. </script>
  716. <style lang="scss">
  717. .el-overlay-dialog .el-dialog.hc-new-dialog.hc-delegate-html-modal {
  718. .hc-new-dialog-body {
  719. padding: 0;
  720. }
  721. .hc-table-form-data-item {
  722. padding: 0;
  723. .el-scrollbar__bar.is-vertical {
  724. right: 0;
  725. }
  726. }
  727. }
  728. .hc-delegate-html-modal {
  729. .hc-delegate-html {
  730. position: relative;
  731. height: calc(100% - 40px);
  732. .hc-table-form-data-item {
  733. background-color: #efefef;
  734. }
  735. &::after {
  736. content: "";
  737. position: absolute;
  738. inset: 0;
  739. background: rgb(161 161 161 / 40%);
  740. z-index: 22;
  741. }
  742. &.is-show {
  743. &::after {
  744. display: none;
  745. z-index: -1;
  746. }
  747. }
  748. }
  749. }
  750. </style>