monthly.vue 13 KB

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