Dayreportattached.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839
  1. <template>
  2. <div>
  3. <!-- 左侧树形结构 -->
  4. <el-container>
  5. <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
  6. <div class="JKWTree-tree" style="height: 70vh;">
  7. <h3>机台生产日报表附加维护</h3>
  8. <el-tree :data="treeData" highlight-current @node-click="handleNodeClick" />
  9. </div>
  10. </layout-sider>
  11. <el-container>
  12. <el-main>
  13. <!-- 按钮区域 -->
  14. <div class="gva-table-box">
  15. <el-form-item>
  16. <el-input v-model="searchInfo" placeholder="输入工单编号或产品名称" style="width: 180px;" />
  17. <el-button type="primary" class="search" icon="search" @click="onSearch"></el-button>
  18. <el-button type="primary" class="bt" icon="plus" @click="onAdd">新增</el-button>
  19. <el-button type="primary" class="bt" icon="delete" @click="onDel">删除</el-button>
  20. <div style="margin-left: auto;">
  21. <el-button type="primary" class="bt" icon="download"
  22. @click="exportExcel">导出到Excel</el-button>
  23. </div>
  24. </el-form-item>
  25. <!-- 数据展示 -->
  26. <el-table ref="multipleTable" style="width: 100%" tooltip-effect="dark" :data="tableData"
  27. row-key="ID" highlight-current-row="true" border :row-style="{ height: '0px' }"
  28. :header-row-style="{ height: '20px' }" :header-cell-style="{ padding: '0px' }"
  29. @selection-change="handleSelectionChange" @row-click="Click" :show-overflow-tooltip="true"
  30. @row-dblclick="doubleClick">
  31. <!-- <el-table-column type="selection" width="55" /> -->
  32. <el-table-column align="left" sortable label="生产日期" prop="sczl_rq" width="105" />
  33. <el-table-column align="left" sortable label="设备编号" prop="sczl_jtbh" width="105" />
  34. <el-table-column align="left" sortable label="设备名称" prop="sczl_sbmc" width="250" />
  35. <el-table-column align="left" sortable label="班组编号" prop="sczl_bzdh" width="105" />
  36. <el-table-column align="left" sortable label="排班工时" prop="sczl_设备运行工时" width="105" />
  37. <el-table-column align="left" sortable label="备注" prop="sczl_desc" width="120" />
  38. <el-table-column align="left" sortable label="创建用户" prop="sys_id" width="120" />
  39. <el-table-column align="left" sortable label="创建时间" prop="sys_rq" width="160" />
  40. <el-table-column align="left" sortable label="修改时间" prop="mod_rq" width="160" />
  41. <el-table-column align="left" sortable 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"
  46. :page-size="limit" :page-sizes="[10, 30, 50, 100]" :total="total"
  47. @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  48. </div>
  49. </div>
  50. <!-- 弹出框 -->
  51. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog"
  52. :title="type === 'create' ? '新增' : '修改'" destroy-on-close width="700px">
  53. <!-- <el-scrollbar height="500px"> -->
  54. <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule"
  55. label-width="80px">
  56. <el-row :gutter="24">
  57. <el-col :span="8">
  58. <el-form-item label="日期" prop="name" class="mab">
  59. <el-input v-model="formData.sczl_rq" type="date" max="9999-12-31" id="日期"
  60. @focus="rqHandleFocus()" @keydown="ent($event, '备注', '日期', '机器')"
  61. placeholder="" />
  62. </el-form-item>
  63. </el-col>
  64. </el-row>
  65. <el-row :gutter="24">
  66. <el-col :span="8">
  67. <el-form-item label="机器" prop="id" class="mab">
  68. <el-input v-model="formData.sczl_jtbh" id="机器"
  69. @keydown="ent($event, '日期', '机器', '组别')" @blur="getJTsubmit()"
  70. style="width: 200px; " placeholder="Enter回车" />
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="16">
  74. <el-input v-model="formData.设备名称" id="设备名称" :readonly=true style="width: 400px;"
  75. placeholder="" />
  76. </el-col>
  77. </el-row>
  78. <el-row :gutter="24">
  79. <el-col :span="8">
  80. <el-form-item label="组别" prop="id" class="mab">
  81. <el-input v-model="formData.sczl_bzdh" id="组别"
  82. @keydown="ent($event, '机器', '组别', '通电时间')" @blur="getBzsubmit()"
  83. style="width: 150px;" placeholder="Enter回车" />
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="8">
  87. <el-form-item label="通电时间" prop="id" label-width="133px" class="mab">
  88. <el-input v-model="formData.sczl_设备运行工时" id="通电时间"
  89. @keydown="ent($event, '组别', '通电时间', '备注')" style="width: 200px;"
  90. placeholder="" />
  91. </el-form-item>
  92. </el-col>
  93. </el-row>
  94. <el-row :gutter="24">
  95. <el-col :span="21">
  96. <el-form-item label="备注" prop="id" class="mab">
  97. <el-input type="textarea" rows="3" cols="50" v-model="formData.sczl_desc"
  98. id="备注" @keydown="ent($event, '通电时间', '备注', '日期')" :clearable="true"
  99. placeholder="" />
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. </el-form>
  104. <!-- </el-scrollbar> -->
  105. <template #footer>
  106. <div class="dialog-footer">
  107. <el-button @click="dialogFormVisible=false">取 消</el-button>
  108. <el-button type="primary" @click="enterDialog">确 定</el-button>
  109. </div>
  110. </template>
  111. </el-dialog>
  112. <el-dialog v-model="GetjtbhVisible" title="选择" destroy-on-close width="600px">
  113. <el-input v-model="searchGetjtbh" placeholder="" style="width: 400px;"></el-input>
  114. <el-button type="primary" icon="search" @click="GetjtbhSubmit" class="search"></el-button>
  115. <el-tree :data="GetJTtreeData" :props="defaultProps" highlight-current="true"
  116. style="width: 500px;" @node-click="GetMachineDedhhandleNodeClick"
  117. @node-dblclick="handleNodeDoubleClick"></el-tree>
  118. </el-dialog>
  119. <el-dialog v-model="BzVisible" title="选择" destroy-on-close width="200px"
  120. @keydown="selectBZ($event)">
  121. <el-table tooltip-effect="dark" :data="selectDataBz" row-key="ID" highlight-current-row="true"
  122. border style="width:100%" ref="table2" @row-dblclick="SelectClickBz">
  123. <el-table-column prop="sczl_bzdh" label="班组" width="150" />
  124. </el-table>
  125. </el-dialog>
  126. </el-main>
  127. </el-container>
  128. </el-container>
  129. </div>
  130. </template>
  131. <script setup>
  132. import {
  133. getproductionaddList,
  134. getproductionaddCount,
  135. adddel,
  136. addedit,
  137. addgetJtbh,
  138. addgetInfo,
  139. reportadd
  140. } from '@/api/jixiaoguanli/jitairibaobiao'
  141. // 全量引入格式化工具 请按需保留
  142. import {
  143. getDictFunc,
  144. formatDate,
  145. formatBoolean,
  146. filterDict,
  147. ReturnArrImg,
  148. onDownloadFile
  149. } from '@/utils/format'
  150. import {
  151. ElMessage,
  152. ElMessageBox
  153. } from 'element-plus'
  154. import {
  155. Search,
  156. Refresh,
  157. Download
  158. } from '@element-plus/icons-vue'
  159. import {
  160. ref,
  161. reactive,
  162. onMounted,
  163. onBeforeMount
  164. } from 'vue'
  165. import {
  166. getPackingSideTable,
  167. getPackingTable
  168. } from '@/api/mes_api_gty/myapi'
  169. import {
  170. Layout,
  171. LayoutContent,
  172. LayoutHeader,
  173. LayoutSider
  174. } from '@arco-design/web-vue'
  175. import {
  176. useUserStore
  177. } from '@/pinia/modules/user'
  178. const userStore = useUserStore()
  179. const sys_id = '[' + userStore.userInfo.userName + '/' + userStore.userInfo.nickName + ']'
  180. defineOptions({
  181. name: '06-packingDocuments'
  182. })
  183. // 侧边栏数据请求
  184. const treeData = reactive([]);
  185. const getTabdata = async () => {
  186. //接口调用函数
  187. const response = await getproductionaddCount();
  188. const transformedData = response.data.map(item => ({
  189. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  190. children: item.sys.map(sysItem => ({
  191. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  192. params: {
  193. date: item.date.replace(/\./g, '-'),
  194. sys_id: sysItem.sys_id,
  195. total: sysItem.count,
  196. },
  197. })),
  198. }));
  199. treeData.splice(0, treeData.length, ...transformedData);
  200. }
  201. getTabdata();
  202. // 自动化生成的字典(可能为空)以及字段
  203. const formData = ref({
  204. sczl_rq: '',
  205. sczl_jtbh: '',
  206. 设备名称: '',
  207. sczl_bzdh: '',
  208. sczl_设备运行工时: '0.00',
  209. sczl_desc: '',
  210. sys_id: sys_id,
  211. })
  212. const initFormData = () => {
  213. formData.value = {
  214. sczl_rq: '',
  215. sczl_jtbh: '',
  216. 设备名称: '',
  217. sczl_bzdh: '',
  218. sczl_设备运行工时: '0.00',
  219. sczl_desc: '',
  220. sys_id: sys_id,
  221. };
  222. }
  223. // 验证规则
  224. const rule = reactive({})
  225. const elFormRef = ref()
  226. const elSearchFormRef = ref()
  227. // =========== 表格控制部分 ===========
  228. const tableData = reactive([])
  229. const detailData = reactive([])
  230. const total = ref(0)
  231. const page = ref(1)
  232. const limit = ref(10)
  233. const searchInfo = ref('')
  234. const searchGetjtbh = ref('')
  235. const params = {
  236. date: '',
  237. sys_id: '',
  238. page: page.value.toString(),
  239. limit: limit.value.toString(),
  240. }
  241. // 分页设置
  242. const handleSizeChange = (val) => {
  243. limit.value = val;
  244. params.limit = val.toString();
  245. getTableData();
  246. }
  247. // 页面跳转
  248. const handleCurrentChange = (val) => {
  249. page.value = val
  250. params.page = val.toString();
  251. getTableData()
  252. }
  253. const getTableData = async () => {
  254. const response = await getproductionaddList(params);
  255. if (response.code === 0) {
  256. tableData.splice(0, tableData.length, ...response.data.rows);
  257. }
  258. }
  259. const handleNodeClick = (node, check) => {
  260. if (node.params) {
  261. params.date = node.params.date;
  262. params.sys_id = node.params.sys_id;
  263. total.value = node.params.total;
  264. handleCurrentChange(1);
  265. }
  266. }
  267. // 搜索
  268. function onSearch() {
  269. }
  270. // ============== 表格控制部分结束 ===============
  271. // 获取需要的字典 可能为空 按需保留
  272. const setOptions = async () => {}
  273. // 获取需要的字典 可能为空 按需保留
  274. setOptions()
  275. // 多选数据
  276. const multipleSelection = ref([])
  277. // 多选
  278. const handleSelectionChange = (val) => {
  279. // multipleSelection.value = val
  280. if (val.length > 0) {
  281. multipleSelection.value = val
  282. const lenth = val.length
  283. // ScrapFactor.gdbh=val[lenth-1].combinedProp.split('-')[0];
  284. // const parts = val[lenth-1].combinedProp2.split('-')
  285. // ScrapFactor.yjno=parts[0];
  286. // ScrapFactor.gxh=parts[1];
  287. // ScrapFactor.type=val[lenth-1].sczl_检验类别
  288. // console.log(ScrapFactor)
  289. lastCellValue = val[lenth - 1].UniqId
  290. val.splice(0, val.length); // 清空 val 数组
  291. }
  292. }
  293. // 批量删除控制标记
  294. const deleteVisible = ref(false)
  295. // 多选删除
  296. const onDelete = async () => {
  297. const ids = []
  298. if (multipleSelection.value.length === 0) {
  299. ElMessage({
  300. type: 'warning',
  301. message: '请选择要删除的数据'
  302. })
  303. return
  304. }
  305. multipleSelection.value &&
  306. multipleSelection.value.map(item => {
  307. ids.push(item.ID)
  308. })
  309. const res = await deleteCompanyByIds({
  310. ids
  311. })
  312. if (res.code === 0) {
  313. ElMessage({
  314. type: 'success',
  315. message: '删除成功'
  316. })
  317. if (tableData.value.length === ids.length && page.value > 1) {
  318. page.value--
  319. }
  320. deleteVisible.value = false
  321. getTableData()
  322. }
  323. }
  324. // 行为控制标记(弹窗内部需要增还是改)
  325. const type = ref('')
  326. // 更新行
  327. const updateCompanyFunc = async (row) => {
  328. const res = await findCompany({
  329. ID: row.ID
  330. })
  331. type.value = 'update'
  332. if (res.code === 0) {
  333. formData.value = res.data.recompany
  334. dialogFormVisible.value = true
  335. }
  336. }
  337. // 弹窗控制标记
  338. const dialogFormVisible = ref(false)
  339. // 打开弹窗
  340. const openDialog = () => {
  341. type.value = 'create'
  342. dialogFormVisible.value = true
  343. }
  344. // 关闭弹窗
  345. const closeDialog = () => {
  346. dialogFormVisible.value = false
  347. formData.value = {
  348. address: '',
  349. image: '',
  350. name: '',
  351. }
  352. }
  353. const rqHandleFocus = () => {
  354. if (formData.value.sczl_rq == '') {
  355. formData.value.sczl_rq = new Date().toISOString().split('T')[0]
  356. }
  357. }
  358. const enterDialog1 = (event) => {
  359. if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
  360. //弹窗提示确认
  361. ElMessageBox.confirm('数据存盘?', '提示', {
  362. confirmButtonText: '确定',
  363. cancelButtonText: '取消',
  364. type: 'warning'
  365. }).then(() => {
  366. enterDialog()
  367. })
  368. } else if (event.keyCode === 39) { // 向右箭头
  369. //弹窗提示确认
  370. ElMessageBox.confirm('数据存盘?', '提示', {
  371. confirmButtonText: '确定',
  372. cancelButtonText: '取消',
  373. type: 'warning'
  374. }).then(() => {
  375. enterDialog()
  376. })
  377. }
  378. }
  379. // 弹窗确定
  380. const enterDialog = async () => {
  381. //弹窗提示确认
  382. ElMessageBox.confirm('数据存盘?', '提示', {
  383. confirmButtonText: '确定',
  384. cancelButtonText: '取消',
  385. type: 'warning'
  386. }).then(() => {
  387. if (formData.value.sczl_rq == '') {
  388. ElMessage({
  389. type: 'error',
  390. message: '请填写日期'
  391. });
  392. document.getElementById('日期').focus()
  393. document.getElementById('日期').select()
  394. return;
  395. }
  396. if (formData.value.sczl_jtbh == '') {
  397. ElMessage({
  398. type: 'error',
  399. message: '请选择机器'
  400. });
  401. document.getElementById('机器').focus()
  402. document.getElementById('机器').select()
  403. return;
  404. }
  405. if (formData.value.sczl_bzdh == '') {
  406. ElMessage({
  407. type: 'error',
  408. message: '请选择班组'
  409. });
  410. document.getElementById('组别').focus()
  411. document.getElementById('组别').select()
  412. return;
  413. }
  414. if (formData.value.sczl_设备运行工时 == '') {
  415. ElMessage({
  416. type: 'error',
  417. message: '请填写通电时间'
  418. });
  419. document.getElementById('通电时间').focus()
  420. document.getElementById('通电时间').select()
  421. return;
  422. }
  423. updateDetailData()
  424. });
  425. }
  426. let table = ref(5);
  427. let lastCellValue = ref()
  428. // 双击表格操作
  429. function doubleClick(row, column, event) {
  430. type.value = 'update';
  431. lastCellValue = row['UniqId'];
  432. table.value = lastCellValue
  433. dialogFormVisible.value = true
  434. AddgetInfo(table.value)
  435. }
  436. // 单击表格操作
  437. function Click(row, column, event) {
  438. lastCellValue = row['UniqId'];
  439. }
  440. //获取详细信息
  441. const AddgetInfo = async (value) => {
  442. const response = await addgetInfo({
  443. UniqId: value
  444. });
  445. if (response.code === 0) {
  446. formData.value = response.data[0];
  447. }
  448. }
  449. //机台回车事件
  450. const getJTsubmit = (event, inputName) => {
  451. addgetJtbh({
  452. sys_mc: ''
  453. }).then(response => {
  454. if (response.code == 0) {
  455. var flag = 0;
  456. for (const arr of response.data[0]['使用部门']) {
  457. if (!flag) {
  458. for (const arr1 of response.data[0][arr]) {
  459. if (arr1['jtbh'] == formData.value.sczl_jtbh) {
  460. flag = 1
  461. break;
  462. }
  463. }
  464. } else {
  465. break;
  466. }
  467. }
  468. if (!flag) {
  469. // 遍历接口返回的数据,构建父子关系
  470. GetJTtreeData.splice(0, GetJTtreeData.length);
  471. response.data.forEach(item => {
  472. const departments = item["使用部门"];
  473. departments.forEach(department => {
  474. const departmentData = {
  475. label: department,
  476. value: department,
  477. children: item[department].map(device => {
  478. return {
  479. label: device["jtbh"] + '/' + device[
  480. "设备名称"],
  481. value: device["jtbh"]
  482. };
  483. })
  484. };
  485. GetJTtreeData.push(departmentData);
  486. });
  487. });
  488. GetjtbhVisible.value = true
  489. }
  490. return
  491. }
  492. })
  493. }
  494. const GetjtbhSubmit = () => {
  495. addgetJtbh({
  496. sys_mc: searchGetjtbh.value
  497. }).then(response => {
  498. if (response.code == 0) {
  499. // 遍历接口返回的数据,构建父子关系
  500. GetJTtreeData.splice(0, GetJTtreeData.length);
  501. response.data.forEach(item => {
  502. const departments = item["使用部门"];
  503. departments.forEach(department => {
  504. const departmentData = {
  505. label: department,
  506. value: department,
  507. children: item[department].map(device => {
  508. return {
  509. label: device["jtbh"] + '/' + device["设备名称"],
  510. value: device["jtbh"]
  511. };
  512. })
  513. };
  514. GetJTtreeData.push(departmentData);
  515. });
  516. });
  517. }
  518. })
  519. }
  520. const GetjtbhVisible = ref(false)
  521. let GetJTtreeData = reactive([]);
  522. const GetMachineDedhhandleNodeClick = (node, check, nodeData) => {
  523. if (!node.children) {
  524. // 点击的是子节点
  525. // 执行相应的子节点单击事件处理逻辑
  526. const splitIndex = node.label.indexOf('/');
  527. formData.value.sczl_jtbh = node.label.substring(0, splitIndex);
  528. formData.value.设备名称 = node.label.substring(splitIndex + 1);
  529. GetjtbhVisible.value = false
  530. }
  531. }
  532. //班组失去焦点事件
  533. const getBzsubmit = () => {
  534. //弹出选择
  535. const data = [{
  536. 'sczl_bzdh': 'A班'
  537. }, {
  538. 'sczl_bzdh': 'B班'
  539. }]
  540. selectDataBz.splice(0, selectDataBz.length, ...data)
  541. if (!GetjtbhVisible.value) {
  542. BzVisible.value = true
  543. setCurrent(selectDataBz[0])
  544. }
  545. }
  546. const table2 = ref()
  547. const setCurrent = (row) => {
  548. setTimeout(() => {
  549. table2.value?.setCurrentRow(row)
  550. // SelectClick(row)
  551. // console.log(row)
  552. // console.log(table)
  553. const {
  554. sczl_bzdh
  555. } = row
  556. formData.value.sczl_bzdh = row.sczl_bzdh
  557. console.log(row)
  558. })
  559. }
  560. //班组选择
  561. const selectDataBz = reactive([])
  562. const BzVisible = ref(false)
  563. const SelectClickBz = (row, column, event) => {
  564. const {
  565. sczl_bzdh
  566. } = row
  567. formData.value.sczl_bzdh = row.sczl_bzdh
  568. BzVisible.value = false
  569. }
  570. const selectBZ = (event) => {
  571. // console.log(selectDataBz.length);
  572. if (event.keyCode === 40) { // Enter 或向下箭头
  573. setCurrent(selectDataBz[1]);
  574. } else if (event.keyCode === 38) {
  575. setCurrent(selectDataBz[0]);
  576. } else if (event.keyCode === 13) {
  577. BzVisible.value = false
  578. }
  579. }
  580. // 更新数据
  581. const updateDetailData = async () => {
  582. const restoredData = {
  583. UniqId: lastCellValue,
  584. sczl_rq: formData.value.sczl_rq,
  585. sczl_jtbh: formData.value.sczl_jtbh,
  586. sczl_bzdh: formData.value.sczl_bzdh,
  587. sczl_设备运行工时: formData.value.sczl_设备运行工时,
  588. sczl_desc: formData.value.sczl_desc,
  589. sys_id: sys_id,
  590. }
  591. if (ADD.value == '新增') {
  592. const response = await reportadd(restoredData);
  593. // ADD.value='1'
  594. // console.log(ADD.value)
  595. ADD.value = '0'
  596. if (response.code == 0) {
  597. ElMessage({
  598. type: 'success',
  599. message: '新增成功',
  600. })
  601. dialogFormVisible.value = false
  602. //刷新侧边栏
  603. getTabdata()
  604. if (params.date != '') {
  605. //刷新页面
  606. getTableData()
  607. }
  608. }
  609. } else {
  610. const response = await addedit(restoredData);
  611. if (response.code == 0) {
  612. ElMessage({
  613. type: 'success',
  614. message: '修改成功',
  615. })
  616. }
  617. dialogFormVisible.value = false
  618. }
  619. }
  620. //键盘 input框跳转
  621. const ent = (event, id1, id2, id3) => {
  622. if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
  623. if (id3 != '') {
  624. if (id2 == '备注') {
  625. document.getElementById(id3).focus()
  626. document.getElementById(id3).select();
  627. enterDialog1()
  628. } else {
  629. document.getElementById(id3).focus()
  630. document.getElementById(id3).select()
  631. }
  632. }
  633. } else if (event.keyCode === 38) { // 向上箭头
  634. if (id1 != '') {
  635. document.getElementById(id1).focus()
  636. document.getElementById(id1).select()
  637. }
  638. } else if (event.keyCode === 8) { // 删除箭头
  639. if (id1 != '' && document.getElementById(id2).value == '') {
  640. document.getElementById(id1).focus()
  641. document.getElementById(id1).setSelectionRange(0, 0)
  642. }
  643. } else if (event.keyCode === 37) { // 向左箭头
  644. if (id1 != '' && document.getElementById(id2).selectionStart == 0) {
  645. document.getElementById(id1).focus()
  646. document.getElementById(id1).select()
  647. }
  648. } else if (event.keyCode === 39) { // 向右箭头
  649. if (id3 != '' && document.getElementById(id2).selectionStart == document.getElementById(id2).value
  650. .length) {
  651. if (id2 == '备注') {
  652. document.getElementById(id3).focus()
  653. document.getElementById(id3).select()
  654. enterDialog1()
  655. } else {
  656. document.getElementById(id3).focus()
  657. document.getElementById(id3).select()
  658. }
  659. }
  660. }
  661. }
  662. const AddDel = (value) => {
  663. if (typeof(lastCellValue) == 'object') {
  664. ElMessage({
  665. type: 'warning',
  666. message: '未选中记录',
  667. })
  668. return
  669. }
  670. ElMessageBox.confirm(
  671. `确认删除这条数据么?`,
  672. '警告', {
  673. confirmButtonText: '确认',
  674. cancelButtonText: '取消',
  675. type: 'warning',
  676. }
  677. ).then(async () => {
  678. const response = await adddel({
  679. UniqId: lastCellValue
  680. });
  681. if (response.code === 0) {
  682. ElMessage({
  683. type: 'success',
  684. message: '删除成功',
  685. })
  686. //刷新侧边栏
  687. getTabdata()
  688. //刷新页面
  689. getTableData()
  690. }
  691. })
  692. }
  693. const ADD = ref('0')
  694. //新增
  695. const onAdd = () => {
  696. type.value = 'create'
  697. ADD.value = '新增'
  698. initFormData()
  699. dialogFormVisible.value = true
  700. // Productionadd()
  701. }
  702. //新增
  703. const Reportadd = async () => {
  704. const response = await reportadd();
  705. if (response.code === 0) {}
  706. getTableData()
  707. }
  708. //删除
  709. function onDel() {
  710. AddDel()
  711. }
  712. // 导出excel
  713. function exportExcel() {
  714. console.log('导出到excel');
  715. }
  716. // 生命周期钩子
  717. onMounted(async () => {});
  718. </script>
  719. <style>
  720. .JKWTree-container {
  721. display: flex;
  722. }
  723. .JKWTree-tree {
  724. width: 300px;
  725. background-color: #fff;
  726. padding: 10px;
  727. margin-right: 20px;
  728. }
  729. .JKWTree-tree h3 {
  730. font-size: 15px;
  731. font-weight: 700;
  732. margin: 10px 0;
  733. }
  734. .JKWTree-content {
  735. flex: 1;
  736. }
  737. /* 选中某行时的背景色*/
  738. .el-table__body tr.current-row>td {
  739. background: #ff80ff !important;
  740. /* 背景颜色 */
  741. }
  742. </style>
  743. <style scoped>
  744. :deep(.el-table td .cell) {
  745. line-height: 20px !important;
  746. }
  747. :deep(.el-tabs__header) {
  748. margin-bottom: 0;
  749. }
  750. .search {
  751. margin-left: 0px !important;
  752. margin-right: 10px !important;
  753. }
  754. .bt {
  755. margin-left: 2px !important;
  756. padding: 3px !important;
  757. font-size: 12px;
  758. }
  759. .el-tabs__header {
  760. margin: 0px !important;
  761. }
  762. .gva-table-box {
  763. padding: 0px !important;
  764. }
  765. .mab {
  766. margin-bottom: 5px;
  767. }
  768. </style>