monthly.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div class="hc-page-layout-box">
  3. <div :style="`width:${leftWidth}px;`" class="hc-layout-left-box bg-white">
  4. <div class="hc-project-box">
  5. <div class="hc-project-icon-box">
  6. <HcIcon name="stack" />
  7. </div>
  8. <div class="ml-2 project-name-box">
  9. <span class="project-alias">{{ projectInfo.name }}</span>
  10. </div>
  11. </div>
  12. <div class="hc-tree-search-box">
  13. <div class="hc-search-tree-val">
  14. <el-input v-model="searchTreeVal" block clearable placeholder="请输入名称关键词检索" @keyup="searchTreeKeyUp">
  15. <template #suffix>
  16. <HcIcon name="search-2" ui="text-xl" />
  17. </template>
  18. </el-input>
  19. </div>
  20. <div v-loading="treeLoading" class="hc-tree-scrollbar" element-loading-text="获取数据中...">
  21. <el-scrollbar>
  22. <KeepAlive>
  23. <template v-if="isSearchTree">
  24. <HcTreeData :datas="searchTreeData" @change="testTreeCheckChange" />
  25. </template>
  26. <template v-else>
  27. <TestTree
  28. :contract-id="contractId" :project-id="projectId"
  29. @change="testTreeCheckChange"
  30. />
  31. </template>
  32. </KeepAlive>
  33. </el-scrollbar>
  34. </div>
  35. </div>
  36. <!-- 左右拖动 -->
  37. <div class="horizontal-drag-line" @mousedown="onmousedown" />
  38. </div>
  39. <div class="hc-page-content-box">
  40. <HcNewCard>
  41. <template #header>
  42. <div class="w-40">
  43. <el-select v-model="searchForm.type" clearable placeholder="请选择材料类别">
  44. <el-option
  45. v-for="item in typeData" :key="item.value" :label="item.label"
  46. :value="item.value"
  47. />
  48. </el-select>
  49. </div>
  50. <div class="w-64 ml-2">
  51. <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  52. </div>
  53. <div class="ml-2">
  54. <el-button type="primary" @click="searchClick">
  55. <HcIcon name="search-2" />
  56. <span>搜索</span>
  57. </el-button>
  58. </div>
  59. </template>
  60. <template #extra>
  61. <HcTooltip keys="tentative_collect_monthly_report">
  62. <el-button hc-btn type="primary">
  63. <HcIcon name="send-plane-2" />
  64. <span>上报</span>
  65. </el-button>
  66. </HcTooltip>
  67. <HcTooltip keys="tentative_collect_monthly_print">
  68. <el-button hc-btn color="#567722">
  69. <HcIcon name="printer" />
  70. <span>打印</span>
  71. </el-button>
  72. </HcTooltip>
  73. <HcTooltip keys="tentative_collect_monthly_download">
  74. <el-button hc-btn color="#A16222">
  75. <HcIcon name="download" />
  76. <span>下载</span>
  77. </el-button>
  78. </HcTooltip>
  79. </template>
  80. <div class="hc-table-ref-box">
  81. <el-table
  82. :data="tableData" :span-method="tableSpanMethod" class="hc-table-diy-box" height="100%"
  83. style="width: 100%" border
  84. >
  85. <el-table-column align="right" label="试验组数" width="300">
  86. <el-table-column align="left" label="试验项目" prop="title" width="220" />
  87. <el-table-column align="center" label="月" prop="month" width="80" />
  88. </el-table-column>
  89. <el-table-column align="center" label="承包人">
  90. <el-table-column align="center" label="合格数" prop="name" />
  91. <el-table-column align="center" label="不合格数" prop="state" />
  92. <el-table-column align="center" label="备注" prop="zip" />
  93. </el-table-column>
  94. <el-table-column align="center" label="操作" width="140">
  95. <template #default="scope">
  96. <!-- scope.row scope.$index -->
  97. <HcTooltip keys="tentative_material_approach_annex">
  98. <el-button
  99. plain size="small" type="primary"
  100. @click="editorsNoteModalClick(scope.row)"
  101. >
  102. 编辑备注
  103. </el-button>
  104. </HcTooltip>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. </div>
  109. <template #action>
  110. <HcPages :pages="searchForm" @change="pageChange" />
  111. </template>
  112. </HcNewCard>
  113. </div>
  114. <!-- 编辑备注 -->
  115. <HcDialog
  116. :loading="editorsNoteLoading" :show="editorsNoteModal" title="编辑备注信息" widths="45rem"
  117. @close="editorsNoteModalClose" @save="editorsNoteModalSave"
  118. >
  119. <el-input v-model="editorsNoteVal" :autosize="{ minRows: 5 }" placeholder="编辑备注信息" type="textarea" />
  120. </HcDialog>
  121. </div>
  122. </template>
  123. <script setup>
  124. import { onMounted, ref, watch } from 'vue'
  125. import { useAppStore } from '~src/store'
  126. import { useRoute, useRouter } from 'vue-router'
  127. import TestTree from './components/TestTree.vue'
  128. import HcTreeData from './components/HcTreeData.vue'
  129. import queryApi from '~api/data-fill/query'
  130. import { getArrValue } from 'js-fast-way'
  131. //初始变量
  132. const router = useRouter()
  133. const useRoutes = useRoute()
  134. const useAppState = useAppStore()
  135. //全局变量
  136. const projectId = ref(useAppState.getProjectId)
  137. const contractId = ref(useAppState.getContractId)
  138. const projectInfo = ref(useAppState.getProjectInfo)
  139. const isCollapse = ref(useAppState.getCollapse)
  140. //监听
  141. watch(() => [
  142. useAppState.getCollapse,
  143. ], ([Collapse]) => {
  144. isCollapse.value = Collapse
  145. })
  146. //渲染完成
  147. onMounted(() => {
  148. })
  149. //树搜索
  150. const isSearchTree = ref(false)
  151. const searchTreeVal = ref('')
  152. const searchTreeData = ref([])
  153. //回车
  154. const treeLoading = ref(false)
  155. const searchTreeKeyUp = (e) => {
  156. if (e.key === 'Enter') {
  157. searchTreeClick()
  158. }
  159. }
  160. const searchTreeClick = async () => {
  161. if (searchTreeVal.value) {
  162. isSearchTree.value = true
  163. treeLoading.value = true
  164. const { data } = await queryApi.searchContractTree({
  165. contractId: contractId.value,
  166. queryValue: searchTreeVal.value,
  167. })
  168. //判断状态
  169. treeLoading.value = false
  170. searchTreeData.value = getArrValue(data)
  171. } else {
  172. treeLoading.value = false
  173. isSearchTree.value = false
  174. }
  175. }
  176. //树被勾选
  177. const nodeItemInfo = ref({})
  178. const testTreeCheckChange = ({ data, checkeds }) => {
  179. console.log(data, checkeds)
  180. //nodeItemInfo.value = data
  181. //searchForm.value.current = 1;
  182. //getTableData()
  183. }
  184. //搜索表单
  185. const searchForm = ref({
  186. type: null, approval: null, betweenTime: null,
  187. current: 1, size: 20, total: 0,
  188. })
  189. //检测类别
  190. const typeData = ref([
  191. { label: '自检', value: '1' },
  192. { label: '抽检', value: '2' },
  193. { label: '平行试验', value: '3' },
  194. { label: '验证试验', value: '4' },
  195. { label: '中心试验', value: '5' },
  196. ])
  197. //日期时间被选择
  198. const betweenTime = ref(null)
  199. const betweenTimeUpdate = ({ arr, query }) => {
  200. betweenTime.value = arr
  201. searchForm.value.betweenTime = query
  202. }
  203. //搜索
  204. const searchClick = () => {
  205. searchForm.value.current = 1
  206. getTableData()
  207. }
  208. //分页被点击
  209. const pageChange = ({ current, size }) => {
  210. searchForm.value.current = current
  211. searchForm.value.size = size
  212. getTableData()
  213. }
  214. //表格合并
  215. const tableSpanMethod = ({ rowIndex, columnIndex }) => {
  216. if (columnIndex === 0) {
  217. if (rowIndex % 2 === 0) {
  218. return {
  219. rowspan: 2,
  220. colspan: 1,
  221. }
  222. } else {
  223. return {
  224. rowspan: 0,
  225. colspan: 0,
  226. }
  227. }
  228. }
  229. }
  230. //获取数据
  231. const tableLoading = ref(false)
  232. const tableData = ref([
  233. {
  234. title: 'No. 189, Grove St, Los Angeles',
  235. month: '本月',
  236. name: '100',
  237. state: '2',
  238. zip: 'CA 90036',
  239. },
  240. {
  241. title: 'No. 189, Grove St, Los Angeles',
  242. month: '累计',
  243. name: '100',
  244. state: '2',
  245. zip: 'CA 90036',
  246. },
  247. {
  248. title: 'No. 189, Grove St, Los Angeles',
  249. month: '本月',
  250. name: '100',
  251. state: '2',
  252. zip: 'CA 90036',
  253. },
  254. {
  255. title: 'No. 189, Grove St, Los Angeles',
  256. month: '累计',
  257. name: '100',
  258. state: '2',
  259. zip: 'CA 90036',
  260. },
  261. {
  262. title: 'No. 189, Grove St, Los Angeles',
  263. month: '本月',
  264. name: '100',
  265. state: '2',
  266. zip: 'CA 90036',
  267. },
  268. {
  269. title: 'No. 189, Grove St, Los Angeles',
  270. month: '累计',
  271. name: '100',
  272. state: '2',
  273. zip: 'CA 90036',
  274. },
  275. ])
  276. const getTableData = () => {
  277. }
  278. //新增/编辑
  279. const editorsNoteModal = ref(false)
  280. const editorsNoteVal = ref('')
  281. const editorsNoteModalClick = (row) => {
  282. editorsNoteModal.value = true
  283. }
  284. //保存
  285. const editorsNoteLoading = ref(false)
  286. const editorsNoteModalSave = () => {
  287. editorsNoteModal.value = true
  288. }
  289. const editorsNoteModalClose = () => {
  290. editorsNoteModal.value = false
  291. }
  292. //左右拖动,改变树形结构宽度
  293. const leftWidth = ref(382)
  294. const onmousedown = () => {
  295. const leftNum = isCollapse.value ? 142 : 272
  296. document.onmousemove = (ve) => {
  297. let diffVal = ve.clientX - leftNum
  298. if (diffVal >= 310 && diffVal <= 900) {
  299. leftWidth.value = diffVal
  300. }
  301. }
  302. document.onmouseup = () => {
  303. document.onmousemove = null
  304. document.onmouseup = null
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. </style>
  310. <style lang="scss">
  311. .hc-table-ref-box {
  312. height: 100%;
  313. border: 0;
  314. .el-table.hc-table-diy-box {
  315. --el-table-bg-color: initial;
  316. --el-table-header-bg-color: #DAE8F3;
  317. --el-table-header-text-color: #50545E;
  318. --el-table-tr-bg-color: #F1F5F8;
  319. --el-fill-color-light: #e7ebee;
  320. --el-table-text-color: #666666;
  321. --el-table-row-hover-bg-color: var(--el-color-primary-light-9);
  322. &.el-table--border {
  323. --el-table-border-color: #d7d7d7;
  324. }
  325. thead.is-group {
  326. background: none;
  327. //表头字体
  328. tr:first-of-type th:first-of-type,
  329. tr:first-of-type th:first-of-type {
  330. .cell {
  331. display: inline-flex;
  332. font-size: 16px;
  333. line-height: initial;
  334. position: relative;
  335. }
  336. }
  337. //表头其他样式
  338. tr:first-of-type th:first-of-type {
  339. border-bottom: none;
  340. .cell {
  341. top: 7px;
  342. }
  343. }
  344. tr:last-of-type th:first-of-type {
  345. border-right: 0;
  346. .cell {
  347. top: -7px;
  348. }
  349. }
  350. //斜线
  351. tr:last-of-type th:nth-of-type(2) {
  352. .cell {
  353. visibility: hidden;
  354. line-height: 0;
  355. padding: 0;
  356. }
  357. &::before, {
  358. content: '';
  359. position: absolute;
  360. width: 1px;
  361. height: 308px;
  362. background-color: #d7d7d7;
  363. display: block;
  364. bottom: 0;
  365. right: 0;
  366. transform: rotate(-75.5deg);
  367. transform-origin: bottom;
  368. }
  369. }
  370. }
  371. }
  372. }
  373. </style>