index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树形结构 -->
  5. <el-scrollbar max-height="75vh">
  6. <el-aside>
  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. <!-- 按钮区域 -->
  20. <div class="gva-table-box">
  21. <div class="gva-btn-list">
  22. <el-row :span="6">
  23. <el-input
  24. v-model="searchInfo"
  25. placeholder="输入工单编号"
  26. style="width: 200px"
  27. />
  28. </el-row>
  29. <el-button
  30. type="primary"
  31. :icon="Search"
  32. @click="onSearch"
  33. >定位</el-button>
  34. <el-button
  35. type="primary"
  36. :icon="Search"
  37. @click="handleShowDetail"
  38. >查改</el-button>
  39. <el-button
  40. type="primary"
  41. :icon="Search"
  42. @click="handleShowAdd"
  43. >新增</el-button>
  44. <div style="margin-left: auto;">
  45. <el-button
  46. type="primary"
  47. :icon="Download"
  48. @click="exportExcel"
  49. >导出到Excel</el-button>
  50. </div>
  51. </div>
  52. <!-- 数据展示 -->
  53. <el-table
  54. ref="multipleTable"
  55. style="width: 100%"
  56. tooltip-effect="dark"
  57. :data="tableData"
  58. row-key="ID"
  59. highlight-current-row
  60. border
  61. show-overflow-tooltip="true"
  62. :row-style="{ height: '20px' }"
  63. :cell-style="{ padding: '0px' }"
  64. :header-row-style="{ height: '20px' }"
  65. :header-cell-style="{ padding: '0px' }"
  66. @selection-change="handleSelectionChange"
  67. @row-click="currentRow = $event"
  68. @row-dblclick="handleShowDetail"
  69. >
  70. <el-table-column
  71. type="selection"
  72. width="55"
  73. />
  74. <!-- 循环渲染列 -->
  75. <el-table-column
  76. v-for=" column in tableColumns "
  77. :key="column.prop"
  78. :prop="column.prop"
  79. :label="column.label"
  80. :width="column.width"
  81. />
  82. </el-table>
  83. <!-- 分页 -->
  84. <div class="gva-pagination">
  85. <el-pagination
  86. v-model:current-page="page"
  87. v-model:page-size="limit"
  88. layout="total, sizes, prev, pager, next, jumper"
  89. :page-sizes="[10, 30, 50, 100]"
  90. :total="total"
  91. @current-change="handleCurrentChange"
  92. @size-change="handleSizeChange"
  93. />
  94. </div>
  95. </div>
  96. <!-- 弹出框 -->
  97. <el-dialog
  98. v-model="dialogFormVisible"
  99. :before-close="closeDialog"
  100. :title="type"
  101. destroy-on-close
  102. width="800px"
  103. >
  104. <!-- <el-scrollbar height="500px"> -->
  105. <el-form
  106. ref="elFormRef"
  107. :model="detailData"
  108. :rules="rule"
  109. label-position="left"
  110. inline
  111. >
  112. <el-form-item
  113. label="员工编号"
  114. >
  115. <el-input
  116. v-model="detailData.Sczl_bh1"
  117. style="width: 100px"
  118. @keyup.enter="handleYgbhEnter"
  119. />
  120. <el-input
  121. v-model="detailData.name"
  122. style="width: 100px; margin-left: 5px"
  123. readonly
  124. />
  125. </el-form-item>
  126. <br>
  127. <el-form-item
  128. label="工序类别"
  129. >
  130. <el-input
  131. v-model="detailData.sczl_Type"
  132. style="width: 150px"
  133. />
  134. </el-form-item>
  135. <el-form-item
  136. label="日期"
  137. >
  138. <el-input
  139. v-model="detailData.Sczl_rq"
  140. style="width: 150px"
  141. />
  142. </el-form-item>
  143. <el-form-item
  144. label="工单编号"
  145. >
  146. <el-input
  147. v-model="detailData.sczl_gdbh"
  148. style="width: 100px"
  149. @keyup.enter="handleGdbhEnter"
  150. />
  151. <el-input
  152. v-model="detailData.Gd_cpmc"
  153. style="width: 400px; margin-left: 5px"
  154. readonly
  155. />
  156. </el-form-item>
  157. <el-form-item
  158. label="工艺流程"
  159. >
  160. <el-input
  161. v-model="detailData.image"
  162. style="width: 300px"
  163. />
  164. <el-input
  165. v-model="detailData.image"
  166. style="width: 100px; margin-left: 5px"
  167. />
  168. </el-form-item>
  169. <el-form-item
  170. label="计件产量"
  171. style="margin-left: 300px"
  172. >
  173. <el-input
  174. v-model="detailData.Sczl_cl"
  175. style="width: 100px"
  176. />
  177. </el-form-item>
  178. <el-form-item
  179. label="工价代号"
  180. >
  181. <el-input
  182. v-model="detailData.sys_bh"
  183. style="width: 200px"
  184. @keyup.enter="handleGjdhEnter"
  185. />
  186. <el-input
  187. v-model="detailData.sys_mc"
  188. style="width: 300px; margin-left: 5px"
  189. readonly
  190. />
  191. </el-form-item>
  192. <el-form-item
  193. label="票号备注"
  194. >
  195. <el-input
  196. v-model="detailData.Sczl_desc"
  197. style="width: 505px"
  198. />
  199. </el-form-item>
  200. </el-form>
  201. <template #footer>
  202. <div class="dialog-footer">
  203. <el-button @click="closeDialog">取 消</el-button>
  204. <el-button
  205. type="primary"
  206. @click="enterDialog"
  207. >确 定</el-button>
  208. </div>
  209. </template>
  210. </el-dialog>
  211. </el-main>
  212. </el-container>
  213. </el-container>
  214. </div>
  215. </template>
  216. <script setup>
  217. import {
  218. createCompany,
  219. deleteCompany,
  220. deleteCompanyByIds,
  221. updateCompany,
  222. findCompany,
  223. getCompanyList
  224. } from '@/api/company'
  225. // 全量引入格式化工具 请按需保留
  226. import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
  227. import { ElMessage, ElMessageBox } from 'element-plus'
  228. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  229. import { ref, reactive, onMounted, onBeforeMount } from 'vue'
  230. import { getSide, getTable, getInfo, getOtherInfo, updateData,add } from '@/api/mes_api_gty/otherDocuments'
  231. defineOptions({
  232. name: '07OtherDocuments'
  233. })
  234. // 侧边栏数据请求
  235. const treeData = reactive([])
  236. const getSideData = async() => {
  237. const response = await getSide()
  238. if (response.code === 0) {
  239. const transformedData = response.data.map(item => ({
  240. label: `${item.date.replace(/-/g, '.')}【产量合计: ${item.counts}】`,
  241. children: item.sys.map(sysItem => ({
  242. label: `${sysItem.Sczl_bh1}(${sysItem.name}) 【产量合计: ${sysItem.count}】`,
  243. params: {
  244. date: item.date.substring(0, 4) + '-' + item.date.substring(4),
  245. Sczl_bh1: sysItem.Sczl_bh1,
  246. },
  247. })),
  248. }))
  249. treeData.splice(0, treeData.length, ...transformedData)
  250. }
  251. }
  252. getSideData()
  253. const elFormRef = ref()
  254. const elSearchFormRef = ref()
  255. // ============== 表格页面 ==============
  256. const tableColumns = [
  257. { prop: 'sczl_Type', label: '计件类型', width: '100' },
  258. { prop: 'Sczl_rq', label: '日期', width: '100' },
  259. { prop: 'Sczl_bh1', label: '员工编号', width: '100' },
  260. { prop: 'name', label: '员工姓名', width: '100' },
  261. { prop: 'sczl_gdbh', label: '工单编号', width: '100' },
  262. { prop: 'Gd_cpmc', label: '产品名称', width: '300' },
  263. { prop: 'Sczl_cl', label: '产量', width: '100' },
  264. { prop: '', label: '千件工价', width: '100' }, // prop 属性值需要补充
  265. { prop: '', label: '工价备注', width: '200' }, // prop 属性值需要补充
  266. { prop: 'Sczl_desc', label: '备注', width: '100' },
  267. { prop: 'Sczl_gxmc', label: '工序名称', width: '100' },
  268. { prop: 'sczl_yjno', label: '印件号', width: '100' },
  269. { prop: 'sczl_gxh', label: '工序号', width: '100' },
  270. { prop: 'sys_id', label: '创建用户', width: '150' },
  271. { prop: 'sys_rq', label: '创建时间', width: '200' },
  272. { prop: 'mod_rq', label: '修改时间', width: '200' },
  273. { prop: 'UniqId', label: 'UNIQID', width: '100' }
  274. ]
  275. const tableData = reactive([])
  276. const currentRow = ref({})
  277. const type = ref('')
  278. const page = ref(1)
  279. const total = ref(0)
  280. const limit = ref(10)
  281. const searchInfo = ref('')
  282. const params = {
  283. date: '',
  284. Sczl_bh1: '',
  285. order: '',
  286. page: page.value.toString(),
  287. limit: limit.value.toString(),
  288. }
  289. // 获取表格数据
  290. const getTableData = async() => {
  291. try {
  292. const response = await getTable(params)
  293. if (response.code === 0) {
  294. total.value = response.data.total
  295. tableData.splice(0, tableData.length, ...response.data.rows)
  296. }
  297. } catch (e) {
  298. console.log(e)
  299. }
  300. }
  301. // 分页设置
  302. const handleSizeChange = () => {
  303. params.limit = limit.value.toString()
  304. getTableData()
  305. }
  306. // 页面跳转
  307. const handleCurrentChange = () => {
  308. params.page = page.value.toString()
  309. getTableData()
  310. }
  311. // 点击左侧节点
  312. const handleNodeClick = (node, check) => {
  313. if (node.params) {
  314. params.date = node.params.date
  315. params.Sczl_bh1 = node.params.Sczl_bh1
  316. params.order = ''
  317. page.value = 1
  318. handleCurrentChange()
  319. }
  320. }
  321. // 搜索
  322. function onSearch() {
  323. params.order = searchInfo.value
  324. params.date = ''
  325. params.Sczl_bh1 = ''
  326. page.value = 1
  327. handleCurrentChange()
  328. }
  329. // ============== 详情页面 ==============
  330. const detailData = reactive({})
  331. // 弹窗控制标记
  332. const dialogFormVisible = ref(false)
  333. // 新增数据
  334. const handleShowAdd = () => {
  335. type.value = '新增'
  336. Object.assign(detailData, currentRow.value)
  337. dialogFormVisible.value = true
  338. }
  339. // 查改
  340. const handleShowDetail = () => {
  341. type.value = '查改'
  342. Object.assign(detailData, currentRow.value)
  343. console.log(detailData)
  344. console.log(currentRow.value)
  345. dialogFormVisible.value = true
  346. }
  347. const handleYgbhEnter = async() => {
  348. const res = await getOtherInfo({ Sczl_bh1: detailData.Sczl_bh1 })
  349. if (res.code === 0) {
  350. detailData.name = res.data.name
  351. }
  352. }
  353. const handleGdbhEnter = async() => {
  354. const res = await getOtherInfo({ Sczl_gdbh: detailData.sczl_gdbh })
  355. if (res.code === 0) {
  356. detailData.Gd_cpmc = res.data.name
  357. }
  358. }
  359. const handleGjdhEnter = async() => {
  360. const res = await getOtherInfo({ Sczl_dedh: detailData.Sczl_dedh })
  361. if (res.code === 0) {
  362. detailData.aaaa = res.data.name
  363. }
  364. }
  365. // 弹窗确定
  366. const enterDialog = async() => {
  367. if (type.value === '查改') {
  368. updateDetailData()
  369. } else if (type.value === '新增') {
  370. addDetailData()
  371. }
  372. }
  373. //新增
  374. const addDetailData = async() => {
  375. const restoredData = {
  376. Sys_id: '[1009/李美芬]',
  377. Sczl_bh1: detailData.Sczl_bh1,
  378. sczl_Type: detailData.sczl_Type,
  379. // name: detailData.name,
  380. Sczl_rq: detailData.Sczl_rq,
  381. Sczl_gdbh: detailData.sczl_gdbh,
  382. Sczl_gxmc: detailData.Sczl_gxmc,
  383. sczl_gxh: detailData.sczl_gxh,
  384. Sczl_cl: detailData.Sczl_cl,
  385. Sczl_dedh: detailData.sys_bh,
  386. Sczl_desc: detailData.Sczl_desc,
  387. }
  388. console.log(restoredData)
  389. const res = await add(restoredData)
  390. console.log(restoredData)
  391. console.log(res)
  392. if (res.code === 0) {
  393. ElMessage({
  394. type: 'success',
  395. message: '新增成功',
  396. })
  397. dialogFormVisible.value = false
  398. }
  399. }
  400. //修改
  401. const updateDetailData = async() => {
  402. const params = {
  403. UniqId: detailData.UniqId,
  404. Sczl_bh1: detailData.Sczl_bh1,
  405. sczl_Type: detailData.sczl_Type,
  406. Sczl_rq: detailData.Sczl_rq,
  407. Sczl_gdbh: detailData.sczl_gdbh,
  408. Sczl_gxmc: '',
  409. sczl_gxh: detailData.sczl_gxh,
  410. Sczl_cl: detailData.Sczl_cl,
  411. Sczl_dedh: '',
  412. Sczl_desc: detailData.Sczl_desc,
  413. }
  414. const res = await updateData(params)
  415. if (res.code === 0) {
  416. ElMessage({
  417. type: 'success',
  418. message: '更新成功',
  419. })
  420. dialogFormVisible.value = false
  421. params.order = ''
  422. // page.value = 1
  423. handleCurrentChange()
  424. }
  425. }
  426. // 获取需要的字典 可能为空 按需保留
  427. const setOptions = async() => {
  428. }
  429. // 获取需要的字典 可能为空 按需保留
  430. setOptions()
  431. // 多选数据
  432. const multipleSelection = ref([])
  433. // 多选
  434. const handleSelectionChange = (val) => {
  435. multipleSelection.value = val
  436. }
  437. // 批量删除控制标记
  438. const deleteVisible = ref(false)
  439. // 多选删除
  440. const onDelete = async() => {
  441. const ids = []
  442. if (multipleSelection.value.length === 0) {
  443. ElMessage({
  444. type: 'warning',
  445. message: '请选择要删除的数据'
  446. })
  447. return
  448. }
  449. multipleSelection.value &&
  450. multipleSelection.value.map(item => {
  451. ids.push(item.ID)
  452. })
  453. const res = await deleteCompanyByIds({ ids })
  454. if (res.code === 0) {
  455. ElMessage({
  456. type: 'success',
  457. message: '删除成功'
  458. })
  459. if (tableData.value.length === ids.length && page.value > 1) {
  460. page.value--
  461. }
  462. deleteVisible.value = false
  463. getTableData()
  464. }
  465. }
  466. // 更新行
  467. const updateCompanyFunc = async(row) => {
  468. const res = await findCompany({ ID: row.ID })
  469. type.value = 'update'
  470. if (res.code === 0) {
  471. detailData.value = res.data.recompany
  472. dialogFormVisible.value = true
  473. }
  474. }
  475. // 打开弹窗
  476. const openDialog = () => {
  477. type.value = 'create'
  478. dialogFormVisible.value = true
  479. }
  480. // 关闭弹窗
  481. const closeDialog = () => {
  482. dialogFormVisible.value = false
  483. detailData.value = {
  484. address: '',
  485. image: '',
  486. name: '',
  487. }
  488. }
  489. // 导出excel
  490. function exportExcel() {
  491. console.log('导出到excel')
  492. }
  493. // 生命周期钩子
  494. onMounted(() => {
  495. })
  496. </script>
  497. <style scoped>
  498. .JKWTree-container {
  499. display: flex;
  500. }
  501. .JKWTree-tree {
  502. width: 300px;
  503. background-color: #fff;
  504. padding: 10px;
  505. margin-right: 20px;
  506. }
  507. .JKWTree-tree h3 {
  508. font-size: 15px;
  509. font-weight: 700;
  510. margin: 10px 0;
  511. }
  512. .JKWTree-content {
  513. flex: 1;
  514. }
  515. /* 选中某行时的背景色 */
  516. :deep(.el-table__body tr.current-row) > td {
  517. background: #ff80ff !important;
  518. }
  519. </style>