bak.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树形结构 -->
  5. <el-scrollbar max-height="80vh">
  6. <el-aside width="280px">
  7. <div class="JKWTree-tree">
  8. <h3>工单超节损核算</h3>
  9. <el-tree
  10. :data="treeData"
  11. highlight-current
  12. @node-click="handleNodeClick"
  13. />
  14. </div>
  15. </el-aside>
  16. </el-scrollbar>
  17. <el-container>
  18. <el-main>
  19. <div class="gva-table-box">
  20. <!-- 按钮区域 -->
  21. <div class="gva-btn-list">
  22. <el-row :span="6">
  23. <el-input
  24. v-model="searchInfo"
  25. placeholder="输入工单编号或产品名称"
  26. />
  27. </el-row>
  28. <el-button
  29. type="primary"
  30. :icon="Search"
  31. @click="onSearch"
  32. >定位</el-button>
  33. <el-button
  34. type="primary"
  35. :icon="Download"
  36. style="margin-left: auto;"
  37. @click="exportExcel"
  38. >导出到Excel</el-button>
  39. </div>
  40. <!-- 数据展示 -->
  41. <el-table
  42. style="width: 100%;height:30vh;"
  43. :data="tableData"
  44. row-key="ID"
  45. highlight-current-row
  46. border
  47. :row-style="{ height: '20px' }"
  48. :cell-style="{ padding: '0px' }"
  49. :header-row-style="{ height: '20px' }"
  50. :header-cell-style="{ padding: '0px' }"
  51. @selection-change="handleSelectionChange"
  52. @row-dblclick="doubleClick"
  53. >
  54. <el-table-column
  55. type="selection"
  56. width="55"
  57. />
  58. <!-- 使用 v-for 循环渲染每一列 -->
  59. <el-table-column
  60. v-for="column in tableCols"
  61. :key="column.prop"
  62. :prop="column.prop"
  63. :label="column.label"
  64. :width="column.width"
  65. show-overflow-tooltip="true"
  66. />
  67. </el-table>
  68. <br>
  69. <el-table
  70. style="width: 100%;height: 40vh;"
  71. row-key="ID"
  72. highlight-current-row
  73. border
  74. :row-style="{ height: '20px' }"
  75. :cell-style="{ padding: '0px' }"
  76. :header-row-style="{ height: '20px' }"
  77. :header-cell-style="{ padding: '0px' }"
  78. @selection-change="handleSelectionChange"
  79. @row-dblclick="doubleClick"
  80. >
  81. <el-table-column
  82. type="selection"
  83. width="55"
  84. />
  85. <!-- 使用 v-for 循环渲染每一列 -->
  86. <el-table-column
  87. v-for="column in tableCols"
  88. :key="column.prop"
  89. :prop="column.prop"
  90. :label="column.label"
  91. :width="column.width"
  92. show-overflow-tooltip="true"
  93. />
  94. </el-table>
  95. </div>
  96. <!-- 弹出框 -->
  97. </el-main>
  98. </el-container>
  99. </el-container>
  100. </div>
  101. </template>
  102. <script setup>
  103. // 全量引入格式化工具 请按需保留
  104. import { ElMessage, ElMessageBox } from 'element-plus'
  105. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  106. import { ref, reactive, onMounted } from 'vue'
  107. import { getSide, getTable } from '@/api/mes_api_gty/orderAccounting'
  108. defineOptions({
  109. name: '12orderAccounting'
  110. })
  111. // 侧边栏数据
  112. const treeData = ref([])
  113. const getSideData = async() => {
  114. const res = await getSide()
  115. if (res.code === 0) {
  116. const { data } = res
  117. const transformedData = []
  118. for (const [key, value] of Object.entries(data)) {
  119. const [date, total] = key.split('-') // 提取日期和数量
  120. const transformedItem = {
  121. label: `${date}(工单数:${total})`,
  122. children: value.map(item => ({
  123. label: `${item['客户编号']}【${item['客户名称']}】(工单数:${item.total})`
  124. })),
  125. }
  126. transformedData.push(transformedItem)
  127. }
  128. treeData.value = transformedData
  129. }
  130. }
  131. getSideData()
  132. // 自动化生成的字典(可能为空)以及字段
  133. const formData = ref({
  134. id: '',
  135. name: '',
  136. date: '',
  137. group: '',
  138. packingOutput: '',
  139. reworkOutput: '',
  140. pieceOutput: '',
  141. order: '',
  142. user: '',
  143. createTime: '',
  144. updateTime: '',
  145. uniqid: '',
  146. })
  147. // 验证规则
  148. const rule = reactive({
  149. })
  150. const elFormRef = ref()
  151. const elSearchFormRef = ref()
  152. // =========== 表格控制部分 ===========
  153. const tableCols = [
  154. { label: '工单编号', prop: 'qczl_gdbh', width: '100' },
  155. { label: '印件号', prop: 'qczl_yjno', width: '100' },
  156. { label: '印件名称', prop: 'Gd_cpmc', width: '400' },
  157. { label: '日期', prop: 'qczl_rq', width: '100' },
  158. { label: '流程单号', prop: 'qczl_num', width: '100' },
  159. { label: '流程单备注', prop: 'qczl_NumDesc', width: '100' },
  160. { label: '总废品', prop: 'qczl_fp', width: '100' },
  161. { label: '废品1', prop: 'sl_lb1', width: '250' },
  162. { label: '废品2', prop: 'sl_lb2', width: '250' },
  163. { label: '废品3', prop: 'sl_lb3', width: '250' },
  164. { label: '废品4', prop: 'sl_lb4', width: '250' },
  165. { label: '废品5', prop: 'sl_lb5', width: '250' },
  166. { label: '废品6', prop: 'sl_lb6', width: '250' },
  167. { label: '废品7', prop: 'sl_lb7', width: '250' },
  168. { label: '废品8', prop: 'sl_lb8', width: '250' },
  169. { label: '废品9', prop: 'sl_lb9', width: '250' },
  170. { label: '废品10', prop: 'sl_lb10', width: '250' },
  171. { label: '废品11', prop: 'sl_lb11', width: '250' },
  172. { label: '废品12', prop: 'sl_lb12', width: '250' },
  173. { label: '废品13', prop: 'sl_lb13', width: '250' },
  174. { label: '废品14', prop: 'sl_lb14', width: '250' },
  175. { label: '废品15', prop: 'sl_lb15', width: '250' },
  176. { label: '废品16', prop: 'sl_lb16', width: '250' },
  177. { label: '废品17', prop: 'sl_lb17', width: '250' },
  178. { label: '创建用户', prop: 'sys_id', width: '200' },
  179. ]
  180. const tableData = reactive([])
  181. const detailData = reactive([
  182. {
  183. gdbh: '2311736',
  184. yjgx: '01-15',
  185. gxmc: '包装(圆切)',
  186. yjmc: '利群(新)小《降焦改版)',
  187. bzcl: '13.00',
  188. fgcl: '0.00',
  189. mxsl: '2500',
  190. jcxs: '1.000',
  191. ly: '',
  192. dedh: '030002002',
  193. },
  194. ])
  195. const total = ref(0)
  196. const page = ref(1)
  197. const limit = ref(10)
  198. const searchInfo = ref('')
  199. const params = {
  200. date: '',
  201. sys_id: '',
  202. page: page.value.toString(),
  203. limit: limit.value.toString(),
  204. }
  205. const getTableData = async() => {
  206. try {
  207. const response = await getOrderVerificationTable(params)
  208. if (response.code === 0) {
  209. tableData.splice(0, tableData.length, ...response.data.rows)
  210. }
  211. } catch (error) {
  212. console.log(error)
  213. }
  214. }
  215. const handleNodeClick = (node, check) => {
  216. if (node.params) {
  217. params.date = node.params.date
  218. params.sys_id = node.params.sys_id
  219. total.value = node.params.total
  220. getTableData()
  221. }
  222. }
  223. // 搜索
  224. function onSearch() {
  225. }
  226. // ============== 表格控制部分结束 ===============
  227. // 获取需要的字典 可能为空 按需保留
  228. const setOptions = async() => {
  229. }
  230. // 获取需要的字典 可能为空 按需保留
  231. setOptions()
  232. // 多选数据
  233. const multipleSelection = ref([])
  234. // 多选
  235. const handleSelectionChange = (val) => {
  236. multipleSelection.value = val
  237. }
  238. // 批量删除控制标记
  239. const deleteVisible = ref(false)
  240. // 多选删除
  241. const onDelete = async() => {
  242. const ids = []
  243. if (multipleSelection.value.length === 0) {
  244. ElMessage({
  245. type: 'warning',
  246. message: '请选择要删除的数据'
  247. })
  248. return
  249. }
  250. multipleSelection.value &&
  251. multipleSelection.value.map(item => {
  252. ids.push(item.ID)
  253. })
  254. const res = await deleteCompanyByIds({ ids })
  255. if (res.code === 0) {
  256. ElMessage({
  257. type: 'success',
  258. message: '删除成功'
  259. })
  260. if (tableData.value.length === ids.length && page.value > 1) {
  261. page.value--
  262. }
  263. deleteVisible.value = false
  264. getTableData()
  265. }
  266. }
  267. // 行为控制标记(弹窗内部需要增还是改)
  268. const type = ref('')
  269. // 更新行
  270. const updateCompanyFunc = async(row) => {
  271. const res = await findCompany({ ID: row.ID })
  272. type.value = 'update'
  273. if (res.code === 0) {
  274. formData.value = res.data.recompany
  275. dialogFormVisible.value = true
  276. }
  277. }
  278. // 弹窗控制标记
  279. const dialogFormVisible = ref(false)
  280. // 打开弹窗
  281. const openDialog = () => {
  282. type.value = 'create'
  283. dialogFormVisible.value = true
  284. }
  285. // 关闭弹窗
  286. const closeDialog = () => {
  287. dialogFormVisible.value = false
  288. formData.value = {
  289. address: '',
  290. image: '',
  291. name: '',
  292. }
  293. }
  294. // 弹窗确定
  295. const enterDialog = async() => {
  296. elFormRef.value?.validate(async(valid) => {
  297. if (!valid) return
  298. let res
  299. switch (type.value) {
  300. case 'create':
  301. res = await createCompany(formData.value)
  302. break
  303. case 'update':
  304. res = await updateCompany(formData.value)
  305. break
  306. default:
  307. res = await createCompany(formData.value)
  308. break
  309. }
  310. if (res.code === 0) {
  311. ElMessage({
  312. type: 'success',
  313. message: '创建/更改成功'
  314. })
  315. closeDialog()
  316. getTableData()
  317. }
  318. })
  319. }
  320. // 双击表格操作
  321. function doubleClick(row, column, event) {
  322. console.log(row, column, event)
  323. // updateCompanyFunc(row);
  324. type.value = 'update'
  325. dialogFormVisible.value = true
  326. }
  327. // 导出excel
  328. function exportExcel() {
  329. console.log('导出到excel')
  330. }
  331. // 生命周期钩子
  332. onMounted(async() => {
  333. })
  334. </script>
  335. <style scoped>
  336. .JKWTree-container {
  337. display: flex;
  338. }
  339. .JKWTree-tree {
  340. width: 300px;
  341. background-color: #fff;
  342. padding: 10px;
  343. margin-right: 20px;
  344. }
  345. .JKWTree-tree h3 {
  346. font-size: 15px;
  347. font-weight: 700;
  348. margin: 10px 0;
  349. }
  350. .JKWTree-content {
  351. flex: 1;
  352. }
  353. /* 选中某行时的背景色 */
  354. :deep(.el-table__body tr.current-row) > td {
  355. background: #ff80ff !important;
  356. }
  357. </style>
  358. <style scoped>
  359. :deep(.el-table td .cell) {
  360. line-height: 20px !important;
  361. }
  362. :deep(.el-tabs__header){
  363. margin-bottom: 0;
  364. }
  365. .search{
  366. margin-left: 0px !important;
  367. margin-right: 10px !important;
  368. }
  369. .bt{
  370. margin-left: 2px !important;
  371. padding: 3px !important;
  372. font-size: 12px;
  373. }
  374. .el-tabs__header{
  375. margin: 0px !important;
  376. }
  377. .gva-table-box{
  378. padding: 0px !important;
  379. }
  380. .mab{
  381. margin-bottom: 5px;
  382. }
  383. </style>