Dayreportattached.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <div>
  3. <!-- 左侧树形结构 -->
  4. <el-container>
  5. <el-aside width="250px">
  6. <div class="JKWTree-tree">
  7. <h3>机台生产日报表附加维护</h3>
  8. <el-tree :data="treeData" :props="defaultProps" highlight-current="true"
  9. @node-click="handleNodeClick"></el-tree>
  10. </div>
  11. </el-aside>
  12. <el-container>
  13. <el-main>
  14. <!-- 按钮区域 -->
  15. <div class="gva-table-box">
  16. <div class="gva-btn-list">
  17. <el-row :span="6">
  18. <el-input v-model="searchInfo" placeholder="输入工单编号或产品名称" />
  19. </el-row>
  20. <el-button type="primary" :icon="Search" @click="onSearch">搜索</el-button>
  21. <el-button type="primary" :icon="Refresh">重置</el-button>
  22. <el-button type="primary" @click="onDel">删除</el-button>
  23. <div style="margin-left: auto;">
  24. <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
  25. </div>
  26. </div>
  27. <!-- 数据展示 -->
  28. <el-table ref="multipleTable" style="width: 100%" tooltip-effect="dark" :data="tableData" row-key="ID"
  29. highlight-current-row="true" border @selection-change="handleSelectionChange"
  30. :show-overflow-tooltip="true" @row-dblclick="doubleClick">
  31. <el-table-column type="selection" width="55" />
  32. <el-table-column align="left" label="生产日期" prop="sczl_rq" width="120"/>
  33. <el-table-column align="left" label="设备编号" prop="sczl_jtbh" width="120"/>
  34. <el-table-column align="left" label="设备名称" prop="sczl_sbmc" width="340"/>
  35. <el-table-column align="left" label="班组编号" prop="sczl_bzdh" width="120"/>
  36. <el-table-column align="left" label="排班工时" prop="sczl_设备运行工时" width="120"/>
  37. <el-table-column align="left" label="备注" prop="sczl_desc" width="120"/>
  38. <el-table-column align="left" label="创建用户" prop="sys_id" width="120"/>
  39. <el-table-column align="left" label="创建时间" prop="sys_rq" width="160"/>
  40. <el-table-column align="left" label="修改时间" prop="mod_rq" width="160"/>
  41. <el-table-column align="left" label="UNIQID" prop="UniqId" width="120"/>
  42. </el-table>
  43. <!-- 分页 -->
  44. <div class="gva-pagination">
  45. <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
  46. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  47. @size-change="handleSizeChange" />
  48. </div>
  49. </div>
  50. <!-- 弹出框 -->
  51. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '添加' : '修改'"
  52. destroy-on-close width="1200px">
  53. <!-- <el-scrollbar height="500px"> -->
  54. <el-form :model="formData" label-position="left" ref="elFormRef" :rules="rule">
  55. <el-row :gutter="20">
  56. <el-col :span="6">
  57. <el-form-item label="日期" prop="name">
  58. <el-row :gutter="20">
  59. <el-col :span="12">
  60. <el-input v-model="formData.sczl_rq" :clearable="true" placeholder="ZT01733" />
  61. </el-col>
  62. </el-row>
  63. </el-form-item>
  64. </el-col>
  65. </el-row>
  66. <el-row :gutter="20">
  67. <el-col :span="8">
  68. <el-row :gutter="20">
  69. <el-col :span="14">
  70. <el-form-item label="机器" prop="id">
  71. <el-input v-model="formData.sczl_jtbh" @keyup.enter.native="getJTsubmit" :clearable="true" placeholder="0.00" />
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="10">
  75. <el-input v-model="formData.设备名称" :clearable="true" placeholder="是" />
  76. </el-col>
  77. </el-row>
  78. </el-col>
  79. </el-row>
  80. <el-row :gutter="20">
  81. <el-col :span="8">
  82. <el-row :gutter="20">
  83. <el-col :span="14">
  84. <el-form-item label="组别" prop="id">
  85. <el-input v-model="formData.sczl_bzdh" :clearable="true" placeholder="0.00" />
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="10">
  89. <el-form-item label="通电时间" prop="id">
  90. <el-input v-model="formData.sczl_设备运行工时" :clearable="true" placeholder="是" />
  91. </el-form-item>
  92. </el-col>
  93. </el-row>
  94. </el-col>
  95. </el-row>
  96. <el-row :gutter="20">
  97. <el-col :span="8">
  98. <el-row :gutter="20">
  99. <el-col :span="14">
  100. <el-form-item label="备注" prop="id" style="margin-top: 10px;">
  101. <el-input v-model="formData.sczl_desc" :clearable="true" placeholder="" />
  102. </el-form-item>
  103. </el-col>
  104. </el-row>
  105. </el-col>
  106. </el-row>
  107. </el-form>
  108. <!-- </el-scrollbar> -->
  109. <template #footer>
  110. <div class="dialog-footer">
  111. <el-button @click="closeDialog">取 消</el-button>
  112. <el-button type="primary" @click="enterDialog">确 定</el-button>
  113. </div>
  114. </template>
  115. </el-dialog>
  116. <el-dialog
  117. v-model="GetjtbhVisible"
  118. title="选择"
  119. destroy-on-close
  120. width="600px"
  121. >
  122. <el-aside width="250px">
  123. <div class="JKWTree-tree">
  124. <el-tree :data="GetJTtreeData" :props="defaultProps" highlight-current="true"
  125. @node-click="GetMachineDedhhandleNodeClick" @node-dblclick="handleNodeDoubleClick"></el-tree>
  126. </div>
  127. </el-aside>
  128. </el-dialog>
  129. </el-main>
  130. </el-container>
  131. </el-container>
  132. </div>
  133. </template>
  134. <script setup>
  135. import {
  136. getproductionaddList,
  137. getproductionaddCount,
  138. adddel,
  139. addedit,
  140. addgetJtbh,
  141. addgetInfo,
  142. } from '@/api/jixiaoguanli/jitairibaobiao'
  143. // 全量引入格式化工具 请按需保留
  144. import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
  145. import { ElMessage, ElMessageBox } from 'element-plus'
  146. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  147. import { ref, reactive, onMounted, onBeforeMount } from 'vue'
  148. import { getPackingSideTable, getPackingTable } from '@/api/mes_api_gty/myapi'
  149. defineOptions({
  150. name: '06-packingDocuments'
  151. })
  152. // 侧边栏数据请求
  153. const treeData = reactive([]);
  154. const getTabdata = async () => {
  155. //接口调用函数
  156. const response = await getproductionaddCount();
  157. console.log(response)
  158. const transformedData = response.data.map(item => ({
  159. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  160. children: item.sys.map(sysItem => ({
  161. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  162. params: {
  163. date: item.date.replace(/\./g, '-'),
  164. sys_id: sysItem.sys_id,
  165. total: sysItem.count,
  166. },
  167. })),
  168. }));
  169. treeData.splice(0, treeData.length, ...transformedData);
  170. }
  171. getTabdata();
  172. // 自动化生成的字典(可能为空)以及字段
  173. const formData = ref({
  174. sczl_rq: '',
  175. sczl_jtbh: '',
  176. 设备名称: '',
  177. sczl_bzdh: '',
  178. sczl_设备运行工时: '',
  179. sczl_desc: '',
  180. })
  181. // 验证规则
  182. const rule = reactive({
  183. })
  184. const elFormRef = ref()
  185. const elSearchFormRef = ref()
  186. // =========== 表格控制部分 ===========
  187. const tableData = reactive([])
  188. const detailData = reactive([])
  189. const total = ref(0)
  190. const page = ref(1)
  191. const limit = ref(10)
  192. const searchInfo = ref('')
  193. const params = {
  194. date: '',
  195. sys_id: '',
  196. page: page.value.toString(),
  197. limit: limit.value.toString(),
  198. }
  199. // 分页设置
  200. const handleSizeChange = (val) => {
  201. limit.value = val;
  202. params.limit = val.toString();
  203. getTableData();
  204. }
  205. // 页面跳转
  206. const handleCurrentChange = (val) => {
  207. page.value = val
  208. params.page = val.toString();
  209. getTableData()
  210. }
  211. const getTableData = async () => {
  212. const response = await getproductionaddList(params);
  213. if (response.code === 0) {
  214. tableData.splice(0, tableData.length, ...response.data.rows);
  215. }
  216. }
  217. const handleNodeClick = (node, check) => {
  218. if (node.params) {
  219. params.date = node.params.date;
  220. params.sys_id = node.params.sys_id;
  221. total.value = node.params.total;
  222. handleCurrentChange(1);
  223. }
  224. }
  225. // 搜索
  226. function onSearch() {
  227. }
  228. // ============== 表格控制部分结束 ===============
  229. // 获取需要的字典 可能为空 按需保留
  230. const setOptions = async () => {
  231. }
  232. // 获取需要的字典 可能为空 按需保留
  233. setOptions()
  234. // 多选数据
  235. const multipleSelection = ref([])
  236. // 多选
  237. const handleSelectionChange = (val) => {
  238. // multipleSelection.value = val
  239. if(val.length>0){
  240. multipleSelection.value = val
  241. const lenth=val.length
  242. // ScrapFactor.gdbh=val[lenth-1].combinedProp.split('-')[0];
  243. // const parts = val[lenth-1].combinedProp2.split('-')
  244. // ScrapFactor.yjno=parts[0];
  245. // ScrapFactor.gxh=parts[1];
  246. // ScrapFactor.type=val[lenth-1].sczl_检验类别
  247. // console.log(ScrapFactor)
  248. lastCellValue=val[lenth-1].UniqId
  249. console.log(val)
  250. val.splice(0, val.length); // 清空 val 数组
  251. console.log(lastCellValue)
  252. }
  253. }
  254. // 批量删除控制标记
  255. const deleteVisible = ref(false)
  256. // 多选删除
  257. const onDelete = async () => {
  258. const ids = []
  259. if (multipleSelection.value.length === 0) {
  260. ElMessage({
  261. type: 'warning',
  262. message: '请选择要删除的数据'
  263. })
  264. return
  265. }
  266. multipleSelection.value &&
  267. multipleSelection.value.map(item => {
  268. ids.push(item.ID)
  269. })
  270. const res = await deleteCompanyByIds({ ids })
  271. if (res.code === 0) {
  272. ElMessage({
  273. type: 'success',
  274. message: '删除成功'
  275. })
  276. if (tableData.value.length === ids.length && page.value > 1) {
  277. page.value--
  278. }
  279. deleteVisible.value = false
  280. getTableData()
  281. }
  282. }
  283. // 行为控制标记(弹窗内部需要增还是改)
  284. const type = ref('')
  285. // 更新行
  286. const updateCompanyFunc = async (row) => {
  287. const res = await findCompany({ ID: row.ID })
  288. type.value = 'update'
  289. if (res.code === 0) {
  290. formData.value = res.data.recompany
  291. dialogFormVisible.value = true
  292. }
  293. }
  294. // 弹窗控制标记
  295. const dialogFormVisible = ref(false)
  296. // 打开弹窗
  297. const openDialog = () => {
  298. type.value = 'create'
  299. dialogFormVisible.value = true
  300. }
  301. // 关闭弹窗
  302. const closeDialog = () => {
  303. dialogFormVisible.value = false
  304. formData.value = {
  305. address: '',
  306. image: '',
  307. name: '',
  308. }
  309. }
  310. // 弹窗确定
  311. const enterDialog = async () => {
  312. updateDetailData()
  313. // elFormRef.value?.validate(async (valid) => {
  314. // if (!valid) return
  315. // let res
  316. // switch (type.value) {
  317. // case 'create':
  318. // res = await createCompany(formData.value)
  319. // break
  320. // case 'update':
  321. // res = await updateCompany(formData.value)
  322. // break
  323. // default:
  324. // res = await createCompany(formData.value)
  325. // break
  326. // }
  327. // if (res.code === 0) {
  328. // ElMessage({
  329. // type: 'success',
  330. // message: '创建/更改成功'
  331. // })
  332. // closeDialog()
  333. // getTableData()
  334. // }
  335. // })
  336. }
  337. let table=ref(5);
  338. let lastCellValue=ref()
  339. // 双击表格操作
  340. function doubleClick(row, column, event) {
  341. type.value = 'update';
  342. lastCellValue= row['UniqId'];
  343. console.log(lastCellValue)
  344. table.value=lastCellValue
  345. dialogFormVisible.value = true
  346. AddgetInfo(table.value)
  347. }
  348. //获取详细信息
  349. const AddgetInfo = async (value) => {
  350. const response = await addgetInfo({UniqId:value});
  351. console.log(response)
  352. if (response.code === 0) {
  353. formData.value=response.data[0];
  354. }
  355. }
  356. //机台回车事件
  357. const getJTsubmit = (event, inputName) => {
  358. GetJtbh()
  359. }
  360. const GetjtbhVisible = ref(false)
  361. let GetJTtreeData = reactive([]);
  362. //获取机台
  363. const GetJtbh = async () => {
  364. const response = await addgetJtbh({sys_mc:''});
  365. if(response.code==0){
  366. // 遍历接口返回的数据,构建父子关系
  367. GetJTtreeData.splice(0, GetJTtreeData.length);
  368. response.data.forEach(item => {
  369. const departments = item["使用部门"];
  370. departments.forEach(department => {
  371. const departmentData = {
  372. label: department,
  373. value: department,
  374. children: item[department].map(device => {
  375. return {
  376. label: device["jtbh"]+'/'+device["设备名称"],
  377. value: device["jtbh"]
  378. };
  379. })
  380. };
  381. GetJTtreeData.push(departmentData);
  382. });
  383. });
  384. // 将父子关系转换为数组
  385. // const transformedData = Object.values(treeData);
  386. // console.log(transformedData)
  387. // GetJTtreeData = transformedData;
  388. // JTBHselectData.splice(0, selectData.length, ...response.data)
  389. GetjtbhVisible.value=true
  390. }
  391. console.log(response)
  392. }
  393. const GetMachineDedhhandleNodeClick = (node,check,nodeData) => {
  394. if (node.children) {
  395. // 点击的是父节点
  396. // 执行相应的父节点单击事件处理逻辑
  397. console.log('2222')
  398. } else {
  399. // 点击的是子节点
  400. // 执行相应的子节点单击事件处理逻辑
  401. console.log('11111');
  402. console.log(node.label)
  403. const splitIndex = node.label.indexOf('/');
  404. formData.value.sczl_jtbh = node.label.substring(0, splitIndex);
  405. formData.value.设备名称 = node.label.substring(splitIndex + 1);
  406. GetjtbhVisible.value=false
  407. }
  408. }
  409. // 更新数据
  410. const updateDetailData = async() => {
  411. const restoredData = {
  412. UniqId: lastCellValue,
  413. sczl_rq:formData.value.sczl_rq,
  414. sczl_jtbh:formData.value.sczl_jtbh,
  415. sczl_bzdh:formData.value.sczl_bzdh,
  416. sczl_设备运行工时:formData.value.sczl_设备运行工时,
  417. sczl_desc:formData.value.sczl_desc,
  418. }
  419. console.log(restoredData)
  420. console.log(lastCellValue)
  421. formData.value.UniqId=lastCellValue
  422. console.log(formData)
  423. restoredData.UniqId='10'
  424. const response = await addedit(restoredData);
  425. // console.log(FormData)
  426. console.log(response)
  427. }
  428. const AddDel = async (value) => {
  429. const response = await adddel({UniqId:'0'});
  430. console.log(response)
  431. if (response.code === 0) {
  432. console.log('333')
  433. }
  434. }
  435. //删除
  436. function onDel() {
  437. AddDel()
  438. }
  439. // 导出excel
  440. function exportExcel() {
  441. console.log('导出到excel');
  442. }
  443. // 生命周期钩子
  444. onMounted(async () => {
  445. });
  446. </script>
  447. <style>
  448. .JKWTree-container {
  449. display: flex;
  450. }
  451. .JKWTree-tree {
  452. width: 300px;
  453. background-color: #fff;
  454. padding: 10px;
  455. margin-right: 20px;
  456. }
  457. .JKWTree-tree h3 {
  458. font-size: 15px;
  459. font-weight: 700;
  460. margin: 10px 0;
  461. }
  462. .JKWTree-content {
  463. flex: 1;
  464. }
  465. /* 选中某行时的背景色*/
  466. .el-table__body tr.current-row>td {
  467. background: #ff80ff !important;
  468. /* 背景颜色 */
  469. }
  470. </style>