index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <template>
  2. <div>
  3. <layout>
  4. <layout-header>
  5. <!-- 按钮 -->
  6. <el-form inline>
  7. <el-form-item>
  8. <el-input
  9. v-model="searchInfo"
  10. placeholder="搜索产品编号或产品名称"
  11. clearable
  12. style="width: 180px;"
  13. />
  14. <el-button
  15. type="primary"
  16. icon="Search"
  17. class="search"
  18. @click="handleSearch"
  19. />
  20. <el-button
  21. type="primary"
  22. icon="edit"
  23. class="bt"
  24. @click="handleShowDetail"
  25. ><i class="el-icon-edit" />查改
  26. </el-button>
  27. <el-button
  28. type="primary"
  29. icon="edit"
  30. class="bt"
  31. @click="handleShowAdd"
  32. >新增
  33. </el-button>
  34. </el-form-item>
  35. </el-form>
  36. <!-- 弹出框 -->
  37. <div>
  38. <!-- 弹出框 -->
  39. <el-dialog
  40. v-model="dialogFormVisible"
  41. :before-close="closeDialog"
  42. title="计件工计时单维护"
  43. destroy-on-close
  44. width="800px"
  45. >
  46. <!-- <el-scrollbar height="500px"> -->
  47. <el-form
  48. ref="elFormRef"
  49. :model="detailData"
  50. label-position="left"
  51. :rules="rule"
  52. >
  53. <!-- 日期 -->
  54. <el-row>
  55. <el-form-item
  56. label="日期"
  57. prop="name"
  58. >
  59. <el-input
  60. v-model="detailData.wgjs_rq"
  61. :clearable="true"
  62. style="width: 100px;"
  63. />
  64. </el-form-item>
  65. </el-row>
  66. <!-- 标题栏 -->
  67. <el-row :gutter="10">
  68. <el-col :span="3">
  69. <span>员工编号</span>
  70. </el-col>
  71. <el-col :span="3">
  72. <span>员工姓名</span>
  73. </el-col>
  74. <el-col :span="3">
  75. <span>计时</span>
  76. </el-col>
  77. <el-col :span="12">
  78. <span>原因备注</span>
  79. </el-col>
  80. <el-col :span="3">
  81. <span>冲月定额</span>
  82. </el-col>
  83. </el-row>
  84. <!-- 员工1 -->
  85. <el-row
  86. :gutter="5"
  87. style="margin-top: 10px;"
  88. >
  89. <el-col :span="3">
  90. <el-input
  91. v-model="detailData.wgjs_bh1"
  92. :clearable="true"
  93. />
  94. </el-col>
  95. <el-col :span="3">
  96. <el-input
  97. v-model="detailData.name1"
  98. :clearable="true"
  99. />
  100. </el-col>
  101. <el-col :span="3">
  102. <el-input
  103. v-model="detailData.wgjs_js1"
  104. :clearable="true"
  105. />
  106. </el-col>
  107. <el-col :span="12">
  108. <el-input
  109. v-model="detailData.wgjs_yy1"
  110. :clearable="true"
  111. />
  112. </el-col>
  113. <el-col :span="3">
  114. <el-input
  115. v-model="detailData.wgjs_冲定额1"
  116. :clearable="true"
  117. />
  118. </el-col>
  119. </el-row>
  120. <!-- 员工2 -->
  121. <el-row
  122. :gutter="5"
  123. style="margin-top: 10px;"
  124. >
  125. <el-col :span="3">
  126. <el-input
  127. v-model="detailData.wgjs_bh2"
  128. :clearable="true"
  129. />
  130. </el-col>
  131. <el-col :span="3">
  132. <el-input
  133. v-model="detailData.name2"
  134. :clearable="true"
  135. />
  136. </el-col>
  137. <el-col :span="3">
  138. <el-input
  139. v-model="detailData.wgjs_js2"
  140. :clearable="true"
  141. />
  142. </el-col>
  143. <el-col :span="12">
  144. <el-input
  145. v-model="detailData.wgjs_yy2"
  146. :clearable="true"
  147. />
  148. </el-col>
  149. <el-col :span="3">
  150. <el-input
  151. v-model="detailData.wgjs_冲定额2"
  152. :clearable="true"
  153. />
  154. </el-col>
  155. </el-row>
  156. <!-- 员工3 -->
  157. <el-row
  158. :gutter="5"
  159. style="margin-top: 10px;"
  160. >
  161. <el-col :span="3">
  162. <el-input
  163. v-model="detailData.wgjs_bh3"
  164. :clearable="true"
  165. />
  166. </el-col>
  167. <el-col :span="3">
  168. <el-input
  169. v-model="detailData.name3"
  170. :clearable="true"
  171. />
  172. </el-col>
  173. <el-col :span="3">
  174. <el-input
  175. v-model="detailData.wgjs_js3"
  176. :clearable="true"
  177. />
  178. </el-col>
  179. <el-col :span="12">
  180. <el-input
  181. v-model="detailData.wgjs_yy3"
  182. :clearable="true"
  183. />
  184. </el-col>
  185. <el-col :span="3">
  186. <el-input
  187. v-model="detailData.wgjs_冲定额3"
  188. :clearable="true"
  189. />
  190. </el-col>
  191. </el-row>
  192. <!-- 员工4 -->
  193. <el-row
  194. :gutter="5"
  195. style="margin-top: 10px;"
  196. >
  197. <el-col :span="3">
  198. <el-input
  199. v-model="detailData.wgjs_bh4"
  200. :clearable="true"
  201. />
  202. </el-col>
  203. <el-col :span="3">
  204. <el-input
  205. v-model="detailData.name4"
  206. :clearable="true"
  207. />
  208. </el-col>
  209. <el-col :span="3">
  210. <el-input
  211. v-model="detailData.wgjs_js4"
  212. :clearable="true"
  213. />
  214. </el-col>
  215. <el-col :span="12">
  216. <el-input
  217. v-model="detailData.wgjs_yy4"
  218. :clearable="true"
  219. />
  220. </el-col>
  221. <el-col :span="3">
  222. <el-input
  223. v-model="detailData.wgjs_冲定额4"
  224. :clearable="true"
  225. />
  226. </el-col>
  227. </el-row>
  228. <!-- 员工5 -->
  229. <el-row
  230. :gutter="5"
  231. style="margin-top: 10px;"
  232. >
  233. <el-col :span="3">
  234. <el-input
  235. v-model="detailData.wgjs_bh5"
  236. :clearable="true"
  237. />
  238. </el-col>
  239. <el-col :span="3">
  240. <el-input
  241. v-model="detailData.name5"
  242. :clearable="true"
  243. />
  244. </el-col>
  245. <el-col :span="3">
  246. <el-input
  247. v-model="detailData.wgjs_js5"
  248. :clearable="true"
  249. />
  250. </el-col>
  251. <el-col :span="12">
  252. <el-input
  253. v-model="detailData.wgjs_yy5"
  254. :clearable="true"
  255. />
  256. </el-col>
  257. <el-col :span="3">
  258. <el-input
  259. v-model="detailData.wgjs_冲定额5"
  260. :clearable="true"
  261. />
  262. </el-col>
  263. </el-row>
  264. <!-- 员工6 -->
  265. <el-row
  266. :gutter="5"
  267. style="margin-top: 10px;"
  268. >
  269. <el-col :span="3">
  270. <el-input
  271. v-model="detailData.wgjs_bh6"
  272. :clearable="true"
  273. />
  274. </el-col>
  275. <el-col :span="3">
  276. <el-input
  277. v-model="detailData.name6"
  278. :clearable="true"
  279. />
  280. </el-col>
  281. <el-col :span="3">
  282. <el-input
  283. v-model="detailData.wgjs_js6"
  284. :clearable="true"
  285. />
  286. </el-col>
  287. <el-col :span="12">
  288. <el-input
  289. v-model="detailData.wgjs_yy6"
  290. :clearable="true"
  291. />
  292. </el-col>
  293. <el-col :span="3">
  294. <el-input
  295. v-model="detailData.wgjs_冲定额6"
  296. :clearable="true"
  297. />
  298. </el-col>
  299. </el-row>
  300. </el-form>
  301. <template #footer>
  302. <div class="dialog-footer">
  303. <el-button @click="closeDialog">取 消</el-button>
  304. <el-button
  305. type="primary"
  306. @click="enterDialog"
  307. >确 定</el-button>
  308. </div>
  309. </template>
  310. </el-dialog>
  311. </div>
  312. </layout-header>
  313. <layout>
  314. <!-- 左侧树侧形结构-->
  315. <layout-sider
  316. :resize-directions="['right']"
  317. :width="220"
  318. style="margin-right: 10px;"
  319. >
  320. <div
  321. class="JKWTree-tree"
  322. style="height: 70vh;"
  323. >
  324. <h3>计件工计时单维护</h3>
  325. <el-tree
  326. :data="treeData"
  327. highlight-current="true"
  328. @node-click="handleNodeClick"
  329. />
  330. </div>
  331. </layout-sider>
  332. <layout-content>
  333. <!-- 数据展示 -->
  334. <el-table
  335. ref="multipleTable"
  336. style="width: 100%"
  337. tooltip-effect="dark"
  338. :data="tableData"
  339. row-key="ID"
  340. highlight-current-row
  341. border
  342. show-overflow-tooltip="true"
  343. :row-style="{ height: '20px' }"
  344. :cell-style="{ padding: '0px' }"
  345. :header-row-style="{ height: '20px' }"
  346. :header-cell-style="{ padding: '0px' }"
  347. @selection-change="handleSelectionChange"
  348. @row-dblclick="doubleClick"
  349. @row-click="Click"
  350. >
  351. <el-table-column
  352. type="selection"
  353. width="55"
  354. />
  355. <!-- 循环渲染列 -->
  356. <el-table-column
  357. v-for=" column in tableColumns "
  358. :key="column.prop"
  359. :prop="column.prop"
  360. :label="column.label"
  361. :width="column.width"
  362. />
  363. </el-table>
  364. <!-- 分页 -->
  365. <div class="gva-pagination">
  366. <el-pagination
  367. v-model:current-page="page"
  368. v-model:page-size="limit"
  369. layout="total, sizes, prev, pager, next, jumper"
  370. :page-sizes="[10, 30, 50, 100]"
  371. :total="total"
  372. @current-change="handleCurrentChange"
  373. @size-change="handleSizeChange"
  374. />
  375. </div>
  376. </layout-content>
  377. </layout>
  378. </layout>
  379. </div>
  380. </template>
  381. <script setup>
  382. // 全量引入格式化工具 请按需保留
  383. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  384. import { ElMessage } from 'element-plus'
  385. import { ref, reactive } from 'vue'
  386. import { getSide, getTable, getDetail, updateData, getLocate, createData } from '@/api/mes_api_gty/timesheet'
  387. defineOptions({
  388. name: '08Timesheet'
  389. })
  390. // 侧边栏数据请求
  391. const treeData = reactive([])
  392. const getSideData = async() => {
  393. const response = await getSide()
  394. if (response.code === 0) {
  395. const transformedData = response.data.map(item => ({
  396. label: item.date,
  397. params: {
  398. date: item.date.substring(0, 4) + '-' + item.date.substring(4),
  399. },
  400. }))
  401. treeData.splice(0, treeData.length, ...transformedData)
  402. }
  403. }
  404. getSideData()
  405. // 验证规则
  406. const rule = reactive({
  407. })
  408. const elFormRef = ref()
  409. // const elSearchFormRef = ref()
  410. // ============== 表格页面 ==============
  411. const tableColumns = [
  412. { prop: 'wgjs_rq', label: '日期', width: 100 },
  413. { prop: 'wgjs_bh1', label: '员工编号1', width: 100 },
  414. { prop: 'name1', label: '姓名1', width: 100 },
  415. { prop: 'department', label: '所在部门', width: 100 },
  416. { prop: 'wgjs_js1', label: '计时1', width: 100 },
  417. { prop: 'wgjs_yy1', label: '原因1', width: 100 },
  418. { prop: 'wgjs_bh2', label: '员工编号2', width: 100 },
  419. { prop: 'name2', label: '姓名2', width: 100 },
  420. { prop: 'wgjs_js2', label: '计时2', width: 100 },
  421. { prop: 'wgjs_yy2', label: '原因2', width: 100 },
  422. { prop: 'wgjs_bh3', label: '员工编号3', width: 100 },
  423. { prop: 'name3', label: '姓名3', width: 100 },
  424. { prop: 'wgjs_js3', label: '计时3', width: 100 },
  425. { prop: 'wgjs_yy3', label: '原因3', width: 100 },
  426. { prop: 'wgjs_bh4', label: '员工编号4', width: 100 },
  427. { prop: 'name4', label: '姓名4', width: 100 },
  428. { prop: 'wgjs_js4', label: '计时4', width: 100 },
  429. { prop: 'wgjs_yy4', label: '原因4', width: 100 },
  430. { prop: 'wgjs_bh5', label: '员工编号5', width: 100 },
  431. { prop: 'name5', label: '姓名5', width: 100 },
  432. { prop: 'wgjs_js5', label: '计时5', width: 100 },
  433. { prop: 'wgjs_yy5', label: '原因5', width: 100 },
  434. { prop: 'wgjs_bh6', label: '员工编号6', width: 100 },
  435. { prop: 'name6', label: '姓名6', width: 100 },
  436. { prop: 'wgjs_js6', label: '计时6', width: 100 },
  437. { prop: 'wgjs_yy6', label: '原因6', width: 100 },
  438. ]
  439. const tableData = reactive([])
  440. const page = ref(1)
  441. const total = ref(0)
  442. const limit = ref(10)
  443. const searchInfo = ref('')
  444. const params = {
  445. date: '',
  446. search: '',
  447. type: '',
  448. }
  449. const getTableData = async(params) => {
  450. const response = await getTable(params)
  451. if (response.code === 0) {
  452. total.value = response.data.total
  453. tableData.splice(0, tableData.length, ...response.data.rows)
  454. }
  455. }
  456. // 搜索
  457. const getLocateData = async(params) => {
  458. const res = await getLocate(params)
  459. if (res.code === 0) {
  460. total.value = res.data.total
  461. tableData.splice(0, tableData.length, ...res.data.rows)
  462. }
  463. }
  464. // 分页设置
  465. const handleSizeChange = () => {
  466. switch (params.type) {
  467. case 'getTableData':
  468. getTableData({ date: params.date, page: page.value.toString(), limit: limit.value.toString() })
  469. break
  470. case 'getLocateData':
  471. getLocateData({ date: params.date.replace('-', ''),
  472. search: params.search,
  473. page: page.value.toString(),
  474. limit: limit.value.toString() })
  475. break
  476. default:
  477. break
  478. }
  479. }
  480. // 页面跳转
  481. const handleCurrentChange = () => {
  482. switch (params.type) {
  483. case 'getTableData':
  484. getTableData({ date: params.date, page: page.value.toString(), limit: limit.value.toString() })
  485. break
  486. case 'getLocateData':
  487. getLocateData({ date: params.date.replace('-', ''),
  488. search: params.search,
  489. page: page.value.toString(),
  490. limit: limit.value.toString() })
  491. break
  492. default:
  493. break
  494. }
  495. }
  496. const handleNodeClick = (node, check) => {
  497. if (node.params) {
  498. params.date = node.params.date
  499. params.type = 'getTableData'
  500. page.value = 1
  501. handleCurrentChange()
  502. }
  503. }
  504. // 新增数据
  505. const handleShowAdd = async() => {
  506. const res = await getDetail({ wgjs_rq: value1.value, wgjs_bh1: value2.value })
  507. if (res.code === 0) {
  508. type.value = 'add'
  509. Object.assign(detailData, res.data)
  510. dialogFormVisible.value = true
  511. }
  512. }
  513. // 搜索
  514. function handleSearch() {
  515. params.search = searchInfo.value
  516. params.type = 'getLocateData'
  517. page.value = 1
  518. handleCurrentChange()
  519. }
  520. // ============== 详情页面 ==============
  521. const detailData = reactive({})
  522. // 行为控制标记(弹窗内部需要增还是改)
  523. const type = ref('')
  524. // 弹窗控制标记
  525. const dialogFormVisible = ref(false)
  526. // 双击表格操作
  527. async function doubleClick(row, column, event) {
  528. type.value = 'update'
  529. const { wgjs_rq, wgjs_bh1 } = row
  530. const res = await getDetail({ wgjs_rq, wgjs_bh1 })
  531. if (res.code === 0) {
  532. Object.assign(detailData, res.data)
  533. dialogFormVisible.value = true
  534. }
  535. }
  536. const value1 = ref()
  537. const value2 = ref()
  538. // 单击表格操作
  539. async function Click(row, column, event) {
  540. const { wgjs_rq, wgjs_bh1 } = row
  541. value1.value = wgjs_rq
  542. value2.value = wgjs_bh1
  543. // console.log(wgjs_rq)
  544. // console.log(wgjs_bh1)
  545. // const res = await getDetail({ wgjs_rq, wgjs_bh1 })
  546. // if (res.code === 0) {
  547. // Object.assign(detailData, res.data)
  548. // dialogFormVisible.value = true
  549. // }
  550. }
  551. // 更新数据
  552. const enterDialog = async() => {
  553. if (type.value === 'update') {
  554. updateDetailData()
  555. } else if (type.value === 'add') {
  556. addDetailData()
  557. }
  558. }
  559. // 新增
  560. const addDetailData = async() => {
  561. const restoredData = {
  562. wgjs_rq: detailData.wgjs_rq,
  563. wgjs_bh1: detailData.wgjs_bh1,
  564. wgjs_js1: detailData.wgjs_js1,
  565. wgjs_yy1: detailData.wgjs_yy1,
  566. wgjs_冲定额1: detailData.wgjs_冲定额1,
  567. wgjs_bh2: detailData.wgjs_bh2,
  568. wgjs_js2: detailData.wgjs_js2,
  569. wgjs_yy2: detailData.wgjs_yy2,
  570. wgjs_冲定额2: detailData.wgjs_冲定额2,
  571. wgjs_bh3: detailData.wgjs_bh3,
  572. wgjs_js3: detailData.wgjs_js3,
  573. wgjs_yy3: detailData.wgjs_yy3,
  574. wgjs_冲定额3: detailData.wgjs_冲定额3,
  575. wgjs_bh4: detailData.wgjs_bh4,
  576. wgjs_js4: detailData.wgjs_js4,
  577. wgjs_yy4: detailData.wgjs_yy4,
  578. wgjs_冲定额4: detailData.wgjs_冲定额4,
  579. wgjs_bh5: detailData.wgjs_bh5,
  580. wgjs_js5: detailData.wgjs_js5,
  581. wgjs_yy5: detailData.wgjs_yy5,
  582. wgjs_冲定额5: detailData.wgjs_冲定额5,
  583. wgjs_bh6: detailData.wgjs_bh6,
  584. wgjs_js6: detailData.wgjs_js6,
  585. wgjs_yy6: detailData.wgjs_yy6,
  586. wgjs_冲定额6: detailData.wgjs_冲定额6,
  587. }
  588. console.log(restoredData)
  589. const res = await createData(restoredData)
  590. console.log(res)
  591. if (res.code === 0) {
  592. ElMessage({
  593. type: 'success',
  594. message: '新增成功',
  595. })
  596. dialogFormVisible.value = false
  597. }
  598. }
  599. // 修改
  600. const updateDetailData = async() => {
  601. const obj = detailData
  602. for (let i = 1; i <= 6; i++) {
  603. delete obj[`name${i}`]
  604. }
  605. const res = await updateData(obj)
  606. if (res.code === 0) {
  607. ElMessage({
  608. type: 'success',
  609. message: '更新成功'
  610. })
  611. params.type = 'getTableData'
  612. // page.value = 1
  613. handleCurrentChange()
  614. // if(response.code==0){
  615. // ElMessage({
  616. // type: 'success',
  617. // message: '更新成功',
  618. // })
  619. // }
  620. dialogFormVisible.value = false
  621. }
  622. }
  623. // 关闭弹窗
  624. const closeDialog = () => {
  625. dialogFormVisible.value = false
  626. }
  627. </script>
  628. <style scoped>
  629. .JKWTree-container {
  630. display: flex;
  631. }
  632. .JKWTree-tree {
  633. width: 100%;
  634. background-color: #fff;
  635. padding: 10px;
  636. margin-right: 20px;
  637. }
  638. .JKWTree-tree h3 {
  639. font-size: 15px;
  640. font-weight: 700;
  641. margin: 10px 0;
  642. }
  643. .JKWTree-content {
  644. flex: 1;
  645. }
  646. /* 选中某行时的背景色 */
  647. :deep(.el-table__body tr.current-row) > td {
  648. background: #ff80ff !important;
  649. }
  650. </style>
  651. <style scoped>
  652. :deep(.el-table td .cell) {
  653. line-height: 25px !important;
  654. }
  655. :deep(.el-tabs__header) {
  656. margin-bottom: 0;
  657. }
  658. .search {
  659. margin-left: 0px !important;
  660. margin-right: 10px !important;
  661. }
  662. .bt {
  663. margin-left: 2px !important;
  664. padding: 3px !important;
  665. font-size: 12px;
  666. }
  667. .el-tabs__header {
  668. margin: 0px !important;
  669. }
  670. .gva-table-box {
  671. padding: 0px !important;
  672. }
  673. .mab {
  674. margin-bottom: 5px;
  675. }
  676. </style>