basicInfo.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <template>
  2. <hc-drawer v-model="isShow" to-id="node-card-target" is-close>
  3. <div class="relative bg-white" style="height: 100%">
  4. <hc-card v-loading="infoLoad" title="基础信息" scrollbar>
  5. <template #header>
  6. <div class="text-bold">基础信息</div>
  7. </template>
  8. <template #extra>
  9. <el-button hc-btn type="success" :loading="handleSaveLoad" @click="handleSave">保存</el-button>
  10. <el-button hc-btn type="warning" @click="handleRefresh">重新获取数据</el-button>
  11. </template>
  12. <div class="header_title">
  13. <div class="text-bold">项目信息</div>
  14. <el-link type="primary" @click="linkCommission">关联委托单</el-link>
  15. </div>
  16. <div class="form-box">
  17. <el-form :model="basicInfoData" label-width="auto">
  18. <el-row :gutter="20">
  19. <el-col :span="12">
  20. <el-form-item label="项目名称">
  21. <el-input v-model="basicInfoData.projectName" />
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="12">
  25. <el-form-item label="工程名称">
  26. <el-input v-model="basicInfoData.projectName" />
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. <el-row :gutter="20">
  31. <el-col :span="12">
  32. <el-form-item label="施工单位">
  33. <el-input v-model="basicInfoData.constructionUnit" />
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="12">
  37. <el-form-item label="监理单位">
  38. <el-input v-model="basicInfoData.supervisionUnit" />
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <el-row :gutter="20">
  43. <el-col :span="12">
  44. <el-form-item label="实验室名称">
  45. <el-input v-model="basicInfoData.labName" />
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="12">
  49. <el-form-item label="合同段/工区">
  50. <el-input v-model="basicInfoData.contractName" />
  51. </el-form-item>
  52. </el-col>
  53. </el-row>
  54. <el-row :gutter="20">
  55. <el-col :span="12">
  56. <el-form-item label="工程部位/用途">
  57. <el-input v-model="basicInfoData.projectPosition" />
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="12">
  61. <el-form-item label="委托单编号">
  62. <el-input v-model="basicInfoData.entrustNo" />
  63. </el-form-item>
  64. </el-col>
  65. </el-row>
  66. <el-row :gutter="20">
  67. <el-col :span="12">
  68. <el-form-item label="记录编号">
  69. <el-input v-model="basicInfoData.recordNo" />
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="12">
  73. <el-form-item label="报告编号">
  74. <el-input v-model="basicInfoData.reportNo" />
  75. </el-form-item>
  76. </el-col>
  77. </el-row>
  78. <el-row :gutter="20">
  79. <el-col :span="12">
  80. <el-form-item label="判断依据">
  81. <el-select
  82. v-model="standardId"
  83. placeholder="请选择"
  84. style="width: 100%"
  85. >
  86. <el-option
  87. v-for="item in basicInfoData.standardVos"
  88. :key="item.id"
  89. :label="item.name"
  90. :value="item.id"
  91. />
  92. </el-select>
  93. </el-form-item>
  94. </el-col>
  95. </el-row>
  96. </el-form>
  97. </div>
  98. <div class="header_title">
  99. <div class="text-bold">样品信息</div>
  100. <el-link type="primary" @click="linkSample">关联样品</el-link>
  101. </div>
  102. <div class="form-box">
  103. <el-form :model="basicInfoData.trialSampleInfoList" label-width="auto">
  104. <el-row :gutter="20">
  105. <el-col :span="12">
  106. <el-form-item label="样品名称">
  107. <el-input v-model="basicInfoData.trialSampleInfoList.materialName" />
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="12">
  111. <el-form-item label="样品编号">
  112. <el-input v-model="basicInfoData.trialSampleInfoList.specificationNumber" />
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. <el-row :gutter="20">
  117. <el-col :span="8">
  118. <el-form-item label="样品描述">
  119. <el-input v-model="basicInfoData.trialSampleInfoList.sampleDescription" />
  120. </el-form-item>
  121. </el-col>
  122. <el-col :span="8">
  123. <el-form-item label="来样/取样时间">
  124. <el-input v-model="basicInfoData.trialSampleInfoList.samplingDate" />
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="8">
  128. <el-form-item label="样品数量">
  129. <el-input v-model="basicInfoData.trialSampleInfoList.materialCount" />
  130. </el-form-item>
  131. </el-col>
  132. </el-row>
  133. <el-row :gutter="20">
  134. <el-col v-for="(item, index) in ypList" :key="item.id" :span="8">
  135. <el-form-item :label="item.name">
  136. <el-select
  137. v-model="ypList[index].value"
  138. placeholder="请选择"
  139. style="width: 100%"
  140. >
  141. <el-option
  142. v-for="item1 in item.info"
  143. :key="item1.id"
  144. :label="item1.name"
  145. :value="item1.id"
  146. />
  147. </el-select>
  148. </el-form-item>
  149. </el-col>
  150. </el-row>
  151. </el-form>
  152. </div>
  153. <div class="header_title">
  154. <div class="text-bold">设备信息</div>
  155. <div>
  156. <el-link type="primary" @click.stop="linkAcquisitionClick(item, index)">关联设备</el-link>
  157. <el-link v-loading="linkLastLoad" type="primary" class="ml-2" @click="linkLast">关联上次设备</el-link>
  158. </div>
  159. </div>
  160. <div>
  161. <hc-table :column="tableColumn" :datas="basicInfoData.trailDeviceUseInfoDTOS">
  162. <template #action="{ row, index }">
  163. <el-link size="small" type="warning">删除</el-link>
  164. </template>
  165. </hc-table>
  166. </div>
  167. </hc-card>
  168. </div>
  169. <!-- 关联取样 -->
  170. <hc-new-dialog
  171. v-model="linksSampleModal" is-table save-text="确认" title="关联取样信息" widths="75rem"
  172. @close="linksSampleModalClose" @save="linksSampleModalSave"
  173. >
  174. <div class="hc-links-sample-modal-box">
  175. <div class="hc-links-sample-tree-box">
  176. <el-scrollbar>
  177. <TestTree
  178. :project-id="projectId" :tenant-id="userInfo?.tenant_id"
  179. :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2"
  180. :entrust="1" @node-tap="linksSampleTreeClick"
  181. />
  182. </el-scrollbar>
  183. </div>
  184. <div class="hc-links-sample-table-box">
  185. <HcTable
  186. ref="tableSampleRef" :column="linksSampleTableColumn" :datas="linksSampleTableData"
  187. :is-index="false" :loading="linksSampleTableLoading" is-new is-check
  188. :check-style="{ width: 29 }"
  189. @selection-change="linksSampleTableSelection"
  190. />
  191. </div>
  192. </div>
  193. </hc-new-dialog>
  194. <!-- 关联委托单 -->
  195. <LinkAssociation v-model="isLinksAssociation" :cid="contractId" :ids="ids" @change="commissionChange" @close="isLinksAssociation = false" />
  196. <!-- 关联设备数据 -->
  197. <hc-new-dialog v-model="isLinkAcquisition" is-table is-footer-center title="关联设备数据" widths="80%" @close="linksAcquisitionClose">
  198. <LinkAcquisition v-if="isLinkAcquisition" v-model="linkAcquisitionLoadDataId" @change="linkAcquisitionChange" />
  199. <template #footer>
  200. <el-button @click="linksAcquisitionClose">取消</el-button>
  201. <el-button hc-btn type="primary" :loading="linksAcquisitionLoading" @click="linksAcquisitionClick">确定</el-button>
  202. </template>
  203. </hc-new-dialog>
  204. </hc-drawer>
  205. </template>
  206. <script setup>
  207. import { nextTick, ref, watch } from 'vue'
  208. import TestTree from '../../material/components/TestTree.vue'
  209. import { useAppStore } from '~src/store'
  210. import dataApi from '~api/tentative/detect/test'
  211. import LinkAssociation from '../../detect/components/linkAssociation.vue'
  212. import LinkAcquisition from '../../detect/components/linkAcquisition.vue'
  213. import codeApi from '~api/basic/code'
  214. import { arrToId, arrToKey, formValidate, getArrValue, getObjVal, getObjValue, isNullES, isString } from 'js-fast-way'
  215. const props = defineProps({
  216. nodeId:{
  217. type: [String, Number],
  218. default: '',
  219. },
  220. dataId: {
  221. type: [String, Number],
  222. default: '',
  223. },
  224. contractId: {
  225. type: [String, Number],
  226. default: '',
  227. },
  228. projectId: {
  229. type: [String, Number],
  230. default: '',
  231. },
  232. ids:{
  233. type: [String, Number],
  234. default: '', //委托单id
  235. },
  236. })
  237. const emit = defineEmits(['change'])
  238. const useAppState = useAppStore()
  239. const userInfo = ref(useAppState.getUserInfo)
  240. const projectInfo = ref(useAppState.getProjectInfo)
  241. const nodeId = ref(props.nodeId)
  242. const dataId = ref(props.dataId)
  243. const projectId = ref(props.projectId)
  244. const contractId = ref(props.contractId)
  245. const ids = ref(props.ids)
  246. const handleRefresh = () => {
  247. getInfoData()
  248. }
  249. const isShow = defineModel('modelValue', {
  250. default: false,
  251. })
  252. const standardId = ref('')
  253. const ypList = ref([]) // 确保 ypList 已定义
  254. const ypLoad = ref(false)
  255. const getYpList = async (id)=>{
  256. ypLoad.value = true
  257. const { error, code, data } = await codeApi.getStandardInfoByStandardId({
  258. standardId: id,
  259. })
  260. //处理数据
  261. ypLoad.value = false
  262. if (!error && code === 200) {
  263. ypList.value = getArrValue(data)
  264. console.log(ypList.value, 'ypList')
  265. } else {
  266. ypList.value = []
  267. }
  268. }
  269. // 监听 standardId 的变化
  270. watch(standardId, async (newVal, oldVal) => {
  271. if (newVal !== oldVal) {
  272. getYpList(newVal)
  273. }
  274. })
  275. //监听
  276. watch(() => [
  277. props.dataId,
  278. props.nodeId,
  279. props.projectId,
  280. props.contractId,
  281. props.ids,
  282. ], ([did, nid, pid, cid, id]) => {
  283. dataId.value = did
  284. nodeId.value = nid
  285. projectId.value = pid
  286. contractId.value = cid
  287. ids.value = id
  288. })
  289. //获取基础信息数据
  290. watch(isShow, (newVal) => {
  291. if (newVal) {
  292. getInfoData()
  293. }
  294. })
  295. const basicInfoData = ref({
  296. trialSampleInfoList:{
  297. materialName:'',
  298. specificationNumber:'',
  299. sampleDescription:'',
  300. samplingDate:'',
  301. },
  302. })
  303. const oldRecordNumber = ref('')//旧记录编号
  304. const oldReportNumber = ref('')//旧报告编号
  305. const recordAutoNumber = ref('')//r记录表自增流水号
  306. const reportAutoNumber = ref('')//报告单自增流水号
  307. const infoLoad = ref(false)
  308. const getInfoData = async () => {
  309. infoLoad.value = true
  310. const { error, code, data } = await codeApi.getBaseInfo({
  311. nodeId: nodeId.value,
  312. id: dataId.value,
  313. projectId: projectId.value,
  314. contractId: contractId.value,
  315. })
  316. //处理数据
  317. infoLoad.value = false
  318. if (!error && code === 200) {
  319. console.log(data, '基础信息数据')
  320. basicInfoData.value = getObjValue(data)
  321. oldRecordNumber.value = data?.recordNo
  322. oldReportNumber.value = data?.reportNo
  323. const { trialSampleInfoList, trailDeviceUseInfoDTOS } = basicInfoData.value
  324. if (!trialSampleInfoList) {
  325. basicInfoData.value.trialSampleInfoList = {
  326. materialName:'',
  327. specificationNumber:'',
  328. sampleDescription:'',
  329. samplingDate:'',
  330. }
  331. }
  332. if (!trailDeviceUseInfoDTOS) {
  333. basicInfoData.value.trailDeviceUseInfoDTOS = []
  334. }
  335. } else {
  336. basicInfoData.value = {}
  337. }
  338. }
  339. const tableColumn = [
  340. { key: 'deviceName', name: '设备名称' },
  341. { key: 'deviceModel', name: '设备型号' },
  342. { key: 'deviceNumber', name: '设备编号' },
  343. { key: 'measuringRange', name: '测量范围' },
  344. { key: 'afterRunCheck', name: '精准度' },
  345. { key: 'useDate', name: '使用日期' },
  346. { key: 'startDate', name: '使用开始时间(h:min)' },
  347. { key: 'endDate', name: '使用结束时间(h:min)' },
  348. { key: 'useDuration', name: '使用时间(min)' },
  349. { key: 'beforeRunCheck', name: '运转前检查情况' },
  350. { key: 'afterRunCheck', name: '运转后检查情况' },
  351. { key: 'managerName', name: '操作人' },
  352. { key: 'remarks', name: '备注' },
  353. { key: 'action', name: '操作' },
  354. ]
  355. //关联取样
  356. const linksSampleModal = ref(false)
  357. const linkSample = () => {
  358. linksSampleModal.value = true
  359. tableSampleCheckedKeys.value = []
  360. }
  361. const linksSampleTableColumn = [
  362. { key: 'materialName', name: '样品名称' },
  363. { key: 'samplingDate', name: '取样日期' },
  364. { key: 'specificationModel', name: '规格型号' },
  365. { key: 'proposedPosition', name: '拟用部位' },
  366. { key: 'userName', name: '取样人' },
  367. ]
  368. const linksSampleTableData = ref([])
  369. const linksSampleTableLoading = ref(false)
  370. const tableSampleRef = ref()
  371. //搜索表单
  372. const linksSampleSearchForm = ref({
  373. nodeId: null, current: 1, size: 20, total: 0,
  374. })
  375. //关联取样树点击事件
  376. const linksSampleTreeClick = ({ data }) => {
  377. linksSampleSearchForm.value.nodeId = data.primaryKeyId
  378. linksSampleSearchForm.value.current = 1
  379. getLinksSampleData()
  380. }
  381. //获取关联数据
  382. const getLinksSampleData = async () => {
  383. linksSampleTableLoading.value = true
  384. const { error, code, data } = await dataApi.sampleListInfo({
  385. ...linksSampleSearchForm.value,
  386. projectId: projectId.value,
  387. contractId: contractId.value,
  388. id: '',
  389. })
  390. //处理数据
  391. linksSampleTableLoading.value = false
  392. if (!error && code === 200) {
  393. linksSampleTableData.value = getArrValue(data)
  394. linksSampleTableData.value.forEach((iten) => {
  395. if (iten.isRelation === 1) {
  396. nextTick(() => {
  397. tableSampleRef.value?.toggleRowSelection(iten, true)
  398. })
  399. }
  400. })
  401. //searchForm.value.total = data.total || 0
  402. } else {
  403. linksSampleTableData.value = []
  404. //searchForm.value.total = 0
  405. }
  406. }
  407. //关闭关联取样
  408. const linksSampleModalClose = () => {
  409. linksSampleModal.value = false
  410. }
  411. const linksSampleModalSave = () => {
  412. linksSampleModal.value = false
  413. console.log(tableSampleCheckedKeys.value, 'tableSampleCheckedKeys.value')
  414. if (tableSampleCheckedKeys.value.length > 0) {
  415. basicInfoData.value.trialSampleInfoList = tableSampleCheckedKeys.value[0]
  416. basicInfoData.value.sampleIds = tableSampleCheckedKeys.value[0].id
  417. }
  418. }
  419. //多选
  420. const tableSampleCheckedKeys = ref([])
  421. const linksSampleTableSelection = (rows) => {
  422. if (rows.length > 1) {
  423. window.$message.warning('只能选择一条数据')
  424. return
  425. }
  426. tableSampleCheckedKeys.value = rows
  427. }
  428. //关联委托单
  429. const linkCommission = ()=>{
  430. isLinksAssociation.value = true
  431. }
  432. //关联委托单
  433. const isLinksAssociation = ref(false)
  434. //委托单确定选择
  435. const commissionChange = (id, data) => {
  436. basicInfoData.value.entrustNo = data.specificationNumber
  437. basicInfoData.value.entrustId = id
  438. }
  439. //关联设备
  440. //关联设备数据
  441. const isLinkAcquisition = ref(false)
  442. const linkAcquisitionLoadDataId = ref('')
  443. const linkAcquisitionIndex = ref(-1)
  444. const linkAcquisitionRow = ref({})
  445. const linkAcquisitionClick = (item, index) => {
  446. isLinkAcquisition.value = true
  447. }
  448. //确定
  449. const linksAcquisitionLoading = ref(false)
  450. const linksAcquisitionClick = async () => {
  451. linksAcquisitionLoading.value = true
  452. linksAcquisitionClose()
  453. }
  454. //关闭关联
  455. const linksAcquisitionClose = () => {
  456. isLinkAcquisition.value = false
  457. linkAcquisitionRow.value = {}
  458. linkAcquisitionLoadDataId.value = null
  459. linkAcquisitionIndex.value = -1
  460. linksAcquisitionLoading.value = false
  461. }
  462. const linkAcquisitionChange = (ids, rows) => {
  463. console.log(ids)
  464. console.log(rows, 'rows')
  465. // tableData.value.push
  466. if (rows.length > 0) {
  467. rows.forEach((item)=>{
  468. basicInfoData.value.trailDeviceUseInfoDTOS.push(item)
  469. })
  470. }
  471. linkAcquisitionLoadDataId.value = ids
  472. basicInfoData.value.deviceUseIds = ids
  473. }
  474. //保存
  475. const handleSaveLoad = ref(false)
  476. const handleSave = async () => {
  477. const standardInfoIds = ypList.value.length > 0
  478. ? ypList.value.filter(item => item.value != null && item.value !== '')
  479. .map(item => item.value)
  480. .join(',') : ''
  481. basicInfoData.value.standardInfoIds = standardInfoIds
  482. basicInfoData.value.oldRecordNumber = oldRecordNumber.value
  483. basicInfoData.value.oldReportNumber = oldReportNumber.value
  484. // emit('change', basicInfoData.value)
  485. handleSaveLoad.value = true
  486. const { error, code, data, msg } = await codeApi.saveBaseInfo({
  487. ...basicInfoData.value,
  488. })
  489. handleSaveLoad.value = false
  490. if (!error && code === 200) {
  491. window.$message.success(msg)
  492. isShow.value = false
  493. }
  494. }
  495. //关联上次设备
  496. const linkLastLoad = ref(false)
  497. const linkLast = async ()=>{
  498. linkLastLoad.value = true
  499. const { error, code, data } = await codeApi.lastTrailDeviceInfo({
  500. nodeId: nodeId.value,
  501. contractId: contractId.value,
  502. })
  503. linkLastLoad.value = false
  504. if (!error && code === 200) {
  505. console.log(data)
  506. let rows = getArrValue(data)
  507. if (rows.length > 0) {
  508. rows.forEach((item)=>{
  509. basicInfoData.value.trailDeviceUseInfoDTOS.push(item)
  510. })
  511. }
  512. }
  513. }
  514. </script>
  515. <style scoped lang="scss">
  516. .text-bold{
  517. font-weight: bold;
  518. }
  519. .header_title{
  520. display: flex;
  521. justify-content: space-between;
  522. background-color: rgb(240, 240, 240);
  523. padding: 10px;
  524. .el-link {
  525. text-decoration: underline;
  526. }
  527. }
  528. .form-box{
  529. margin-top: 10px;
  530. padding-left:30px ;
  531. padding-right:30px ;
  532. }
  533. .hc-links-sample-modal-box {
  534. position: relative;
  535. height: 100%;
  536. display: flex;
  537. .hc-links-sample-tree-box,
  538. .hc-links-sample-table-box {
  539. position: relative;
  540. width: 300px;
  541. height: 100%;
  542. }
  543. .hc-links-sample-tree-box {
  544. margin-right: 24px;
  545. border: 1px solid #EEEEEE;
  546. }
  547. .hc-links-sample-table-box {
  548. flex: 1;
  549. }
  550. }
  551. </style>