index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div>
  3. <!-- 左侧树形结构 -->
  4. <el-container>
  5. <el-scrollbar max-height="80vh">
  6. <el-aside width="280px">
  7. <div class="JKWTree-tree">
  8. <h3>计件员工加班费核查</h3>
  9. <el-tree :data="treeData" :props="defaultProps" highlight-current="true"
  10. @node-click="handleNodeClick"></el-tree>
  11. </div>
  12. </el-aside>
  13. </el-scrollbar>
  14. <el-container>
  15. <el-main>
  16. <div class="gva-table-box">
  17. <div class="gva-btn-list">
  18. <el-row :span="6">
  19. <el-input v-model="searchInfo" placeholder="输入工单编号或产品名称" />
  20. </el-row>
  21. <!-- 按钮区域 -->
  22. <el-button type="primary" :icon="Search" @click="onSearch">搜索</el-button>
  23. <el-button type="primary" :icon="Refresh">重置</el-button>
  24. <div style="margin-left: auto;">
  25. <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
  26. </div>
  27. </div>
  28. <!-- 数据展示 -->
  29. <el-table ref="multipleTable" style="width: 100%;height:30vh;" tooltip-effect="dark" :data="tableData"
  30. row-key="ID" highlight-current-row="true" border :row-style="{ height: '20px' }"
  31. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  32. :header-cell-style="{ padding: '0px' }" @selection-change="handleSelectionChange">
  33. <el-table-column type="selection" width="55" />
  34. <!-- 使用 v-for 循环渲染每一列 -->
  35. <el-table-column v-for="column in tableCols" :key="column.prop" :prop="column.prop" :label="column.label"
  36. :width="column.width" show-overflow-tooltip="true"></el-table-column>
  37. </el-table>
  38. <br>
  39. <el-table ref="multipleTable" style="width: 100%;height: 40vh;" tooltip-effect="dark" :data="tableData"
  40. row-key="ID" highlight-current-row="true" border :row-style="{ height: '20px' }"
  41. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  42. :header-cell-style="{ padding: '0px' }" @selection-change="handleSelectionChange">
  43. <el-table-column type="selection" width="55" />
  44. <!-- 使用 v-for 循环渲染每一列 -->
  45. <el-table-column v-for="column in tableCols" :key="column.prop" :prop="column.prop" :label="column.label"
  46. :width="column.width" show-overflow-tooltip="true"></el-table-column>
  47. </el-table>
  48. </div>
  49. </el-main>
  50. </el-container>
  51. </el-container>
  52. </div>
  53. </template>
  54. <script setup>
  55. import {
  56. createCompany,
  57. deleteCompany,
  58. deleteCompanyByIds,
  59. updateCompany,
  60. findCompany,
  61. getCompanyList
  62. } from '@/api/company'
  63. // 全量引入格式化工具 请按需保留
  64. import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
  65. import { ElMessage, ElMessageBox } from 'element-plus'
  66. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  67. import { ref, reactive, onMounted, onBeforeMount } from 'vue'
  68. import { getOrderVerificationSideTable, getOrderVerificationTable } from '@/api/mes_api_gty/myapi'
  69. defineOptions({
  70. name: '06-packingDocuments'
  71. })
  72. // 侧边栏数据请求
  73. const treeData = reactive([]);
  74. const getSideData = async () => {
  75. const response = await getOrderVerificationSideTable();
  76. if (response.code === 0) {
  77. const transformedData = response.data.map(item => ({
  78. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  79. children: item.sys.map(sysItem => ({
  80. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  81. params: {
  82. date: item.date.replace(/\./g, '-'),
  83. sys_id: sysItem.sys_id,
  84. total: sysItem.count,
  85. },
  86. })),
  87. }));
  88. treeData.splice(0, treeData.length, ...transformedData);
  89. }
  90. };
  91. getSideData();
  92. // 自动化生成的字典(可能为空)以及字段
  93. const formData = ref({
  94. id: '',
  95. name: '',
  96. date: '',
  97. group: '',
  98. packingOutput: '',
  99. reworkOutput: '',
  100. pieceOutput: '',
  101. order: '',
  102. user: '',
  103. createTime: '',
  104. updateTime: '',
  105. uniqid: '',
  106. })
  107. // 验证规则
  108. const rule = reactive({
  109. })
  110. const elFormRef = ref()
  111. const elSearchFormRef = ref()
  112. // =========== 表格控制部分 ===========
  113. const tableCols = [
  114. { label: '工单编号', prop: 'qczl_gdbh', width: '100' },
  115. { label: '印件号', prop: 'qczl_yjno', width: '100' },
  116. { label: '印件名称', prop: 'Gd_cpmc', width: '400', showOverflowTooltip: true },
  117. { label: '日期', prop: 'qczl_rq', width: '100' },
  118. { label: '流程单号', prop: 'qczl_num', width: '100' },
  119. { label: '流程单备注', prop: 'qczl_NumDesc', width: '100' },
  120. { label: '总废品', prop: 'qczl_fp', width: '100' },
  121. { label: '废品1', prop: 'sl_lb1', width: '250' },
  122. { label: '废品2', prop: 'sl_lb2', width: '250' },
  123. { label: '废品3', prop: 'sl_lb3', width: '250' },
  124. { label: '废品4', prop: 'sl_lb4', width: '250' },
  125. { label: '废品5', prop: 'sl_lb5', width: '250' },
  126. { label: '废品6', prop: 'sl_lb6', width: '250' },
  127. { label: '废品7', prop: 'sl_lb7', width: '250' },
  128. { label: '废品8', prop: 'sl_lb8', width: '250' },
  129. { label: '废品9', prop: 'sl_lb9', width: '250' },
  130. { label: '废品10', prop: 'sl_lb10', width: '250' },
  131. { label: '废品11', prop: 'sl_lb11', width: '250' },
  132. { label: '废品12', prop: 'sl_lb12', width: '250' },
  133. { label: '废品13', prop: 'sl_lb13', width: '250' },
  134. { label: '废品14', prop: 'sl_lb14', width: '250' },
  135. { label: '废品15', prop: 'sl_lb15', width: '250' },
  136. { label: '废品16', prop: 'sl_lb16', width: '250' },
  137. { label: '废品17', prop: 'sl_lb17', width: '250' },
  138. { label: '创建用户', prop: 'sys_id', width: '200' },
  139. ];
  140. const tableData = reactive([])
  141. const detailData = reactive([
  142. {
  143. gdbh: '2311736',
  144. yjgx: '01-15',
  145. gxmc: '包装(圆切)',
  146. yjmc: '利群(新)小《降焦改版)',
  147. bzcl: '13.00',
  148. fgcl: '0.00',
  149. mxsl: '2500',
  150. jcxs: '1.000',
  151. ly: '',
  152. dedh: '030002002',
  153. },
  154. ])
  155. const total = ref(0)
  156. const page = ref(1)
  157. const limit = ref(10)
  158. const searchInfo = ref('')
  159. const params = {
  160. date: '',
  161. sys_id: '',
  162. page: page.value.toString(),
  163. limit: limit.value.toString(),
  164. }
  165. const getTableData = async () => {
  166. try {
  167. const response = await getOrderVerificationTable(params);
  168. if (response.code === 0) {
  169. tableData.splice(0, tableData.length, ...response.data.rows);
  170. }
  171. } catch (error) {
  172. console.log(error);
  173. }
  174. }
  175. const handleNodeClick = (node, check) => {
  176. if (node.params) {
  177. params.date = node.params.date;
  178. params.sys_id = node.params.sys_id;
  179. total.value = node.params.total;
  180. getTableData();
  181. }
  182. }
  183. // 搜索
  184. function onSearch() {
  185. }
  186. // ============== 表格控制部分结束 ===============
  187. // 获取需要的字典 可能为空 按需保留
  188. const setOptions = async () => {
  189. }
  190. // 获取需要的字典 可能为空 按需保留
  191. setOptions()
  192. // 多选数据
  193. const multipleSelection = ref([])
  194. // 多选
  195. const handleSelectionChange = (val) => {
  196. multipleSelection.value = val
  197. }
  198. // 批量删除控制标记
  199. const deleteVisible = ref(false)
  200. // 多选删除
  201. const onDelete = async () => {
  202. const ids = []
  203. if (multipleSelection.value.length === 0) {
  204. ElMessage({
  205. type: 'warning',
  206. message: '请选择要删除的数据'
  207. })
  208. return
  209. }
  210. multipleSelection.value &&
  211. multipleSelection.value.map(item => {
  212. ids.push(item.ID)
  213. })
  214. const res = await deleteCompanyByIds({ ids })
  215. if (res.code === 0) {
  216. ElMessage({
  217. type: 'success',
  218. message: '删除成功'
  219. })
  220. if (tableData.value.length === ids.length && page.value > 1) {
  221. page.value--
  222. }
  223. deleteVisible.value = false
  224. getTableData()
  225. }
  226. }
  227. // 导出excel
  228. function exportExcel() {
  229. console.log('导出到excel');
  230. }
  231. // 生命周期钩子
  232. onMounted(async () => {
  233. });
  234. </script>
  235. <style scoped>
  236. .JKWTree-container {
  237. display: flex;
  238. }
  239. .JKWTree-tree {
  240. width: 300px;
  241. background-color: #fff;
  242. padding: 10px;
  243. margin-right: 20px;
  244. }
  245. .JKWTree-tree h3 {
  246. font-size: 15px;
  247. font-weight: 700;
  248. margin: 10px 0;
  249. }
  250. .JKWTree-content {
  251. flex: 1;
  252. }
  253. /* 选中某行时的背景色*/
  254. ::v-deep .el-table__body tr.current-row>td {
  255. background: #ff80ff !important;
  256. }
  257. </style>