leave.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <hc-card-item class="hc-test-sample-card-item">
  3. <template #header>
  4. <div class="w-200px">
  5. <el-select v-model="searchForm.contractId" placeholder="选择合同段" filterable block>
  6. <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
  7. </el-select>
  8. </div>
  9. <div class="ml-2 w-250px">
  10. <hc-date-picker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  11. </div>
  12. <div class="ml-2 w-250px">
  13. <hc-search-input v-model="searchForm.materialName" @search="searchClick" />
  14. </div>
  15. </template>
  16. <template #extra>
  17. <el-button type="danger" :disabled="tableCheckedKeys.length <= 0" @click="batchDispose">处理样品</el-button>
  18. </template>
  19. <hc-table
  20. :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check
  21. :index-style="{ width: 60 }" :check-style="{ width: 29 }" @selection-change="tableSelection"
  22. >
  23. <template #action="{ row }">
  24. <el-link type="primary" @click="rowView(row)">查看报告</el-link>
  25. <el-link type="danger" @click="rowDispose(row)">处理样品</el-link>
  26. </template>
  27. </hc-table>
  28. <template #action>
  29. <hc-pages :pages="searchForm" @change="pageChange" />
  30. </template>
  31. <!-- 样品处理 -->
  32. <hc-new-dialog v-model="disposeModal" is-footer-center title="样品处理" widths="50rem" @close="disposeClose">
  33. <div v-if="batchList.length > 0" class="relative mb-24px">
  34. <hc-table :column="batchColumn" :datas="batchList" :is-index="false" />
  35. </div>
  36. <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="left" label-width="auto">
  37. <el-form-item label="处理原因:" prop="key1">
  38. <el-input v-model="formModel.key1" type="textarea" :rows="4" resize="none" />
  39. </el-form-item>
  40. </el-form>
  41. <template #footer>
  42. <el-button @click="disposeClose">取消</el-button>
  43. <el-button hc-btn type="primary" @click="disposeSave">确定</el-button>
  44. </template>
  45. </hc-new-dialog>
  46. </hc-card-item>
  47. </template>
  48. <script setup>
  49. import { onMounted, ref, watch } from 'vue'
  50. import { useAppStore } from '~src/store'
  51. import { getErtractInfo } from '~api/other'
  52. import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
  53. import mainApi from '~api/tentative/material/testSample'
  54. //参数
  55. const props = defineProps({
  56. tree: {
  57. type: Object,
  58. default: () => ({}),
  59. },
  60. })
  61. //变量
  62. const store = useAppStore()
  63. const projectId = ref(store.getProjectId)
  64. const contractId = ref(store.getContractId)
  65. //渲染完成
  66. onMounted(() => {
  67. getContractData()
  68. })
  69. //监听数据
  70. const treeInfo = ref(props.tree)
  71. watch(() => props.tree, (obj) => {
  72. treeInfo.value = getObjValue(obj)
  73. searchClick()
  74. })
  75. //搜索表单
  76. const searchForm = ref({
  77. status: 5, startTime: null, endTime: null, materialName: null,
  78. current: 1, size: 20, total: 0,
  79. })
  80. //获取合同段信息
  81. const contractData = ref([])
  82. const getContractData = async () => {
  83. const { data } = await getErtractInfo({
  84. projectId: projectId.value,
  85. contractId: contractId.value,
  86. })
  87. const res = getArrValue(data)
  88. contractData.value = res
  89. if (res.length > 0) {
  90. searchForm.value.contractId = res[0].id
  91. searchClick()
  92. }
  93. }
  94. //日期时间被选择
  95. const betweenTime = ref(null)
  96. const betweenTimeUpdate = ({ arr }) => {
  97. betweenTime.value = arr
  98. if (arr.length > 0) {
  99. searchForm.value.startTime = arr[0]
  100. searchForm.value.endTime = arr[1]
  101. } else {
  102. searchForm.value.startTime = null
  103. searchForm.value.endTime = null
  104. }
  105. }
  106. //搜索
  107. const searchClick = () => {
  108. searchForm.value.current = 1
  109. getTableData()
  110. }
  111. //分页被点击
  112. const pageChange = ({ current, size }) => {
  113. searchForm.value.current = current
  114. searchForm.value.size = size
  115. getTableData()
  116. }
  117. //表格数据
  118. const tableColumn = ref([
  119. { key: 'materialName', name: '样品名称' },
  120. { key: 'specificationModel', name: '规格型号', align: 'center' },
  121. { key: 'materialCount', name: '试样数量', align: 'center' },
  122. { key: 'expCount', name: '试验数量', align: 'center' },
  123. { key: 'key5', name: '留样数量', align: 'center' },
  124. { key: 'calculationUnit', name: '计算单位', align: 'center' },
  125. { key: 'proposedPosition', name: '拟用部位' },
  126. { key: 'representativeCount', name: '代表数量', align: 'center' },
  127. { key: 'resamTime', name: '留样时间', align: 'center' },
  128. { key: 'action', name: '操作', width: 150, align: 'center' },
  129. ])
  130. const tableData = ref([])
  131. //获取表格数据
  132. const tableLoading = ref(false)
  133. const getTableData = async () => {
  134. const { primaryKeyId } = treeInfo.value
  135. if (isNullES(primaryKeyId)) return
  136. tableLoading.value = true
  137. const { error, code, data } = await mainApi.queryPage({
  138. ...searchForm.value,
  139. projectId: projectId.value,
  140. contractId: contractId.value,
  141. nodeId: primaryKeyId || '',
  142. })
  143. //处理数据
  144. tableLoading.value = false
  145. if (!error && code === 200) {
  146. tableData.value = getArrValue(data?.records)
  147. searchForm.value.total = data.total || 0
  148. } else {
  149. tableData.value = []
  150. searchForm.value.total = 0
  151. }
  152. }
  153. //多选
  154. const tableCheckedKeys = ref([])
  155. const tableSelection = (rows) => {
  156. tableCheckedKeys.value = rows
  157. }
  158. //表单数据
  159. const formRef = ref(null)
  160. const formModel = ref({})
  161. const formRules = {
  162. key1: {
  163. required: true,
  164. trigger: 'blur',
  165. message: '请填写处理原因',
  166. },
  167. }
  168. //弹窗
  169. const disposeModal = ref(false)
  170. const batchColumn = ref([
  171. { key: 'key1', name: '取样名称' },
  172. { key: 'key2', name: '留样数量' },
  173. { key: 'key3', name: '拟用部位' },
  174. { key: 'key4', name: '留样时间' },
  175. ])
  176. const batchList = ref([])
  177. //批量处理样品
  178. const batchDispose = () => {
  179. batchList.value = tableCheckedKeys.value
  180. disposeModal.value = true
  181. }
  182. //处理样品
  183. const rowDispose = (row) => {
  184. batchList.value = []
  185. disposeModal.value = true
  186. }
  187. //提交保存
  188. const disposeSave = async () => {
  189. disposeClose()
  190. }
  191. //关闭弹窗
  192. const disposeClose = () => {
  193. disposeModal.value = false
  194. batchList.value = []
  195. }
  196. //查看报告
  197. const rowView = (row) => {
  198. }
  199. </script>