yuangongrigongzi.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  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. <layout-sider
  13. :resize-directions="['right']"
  14. :width="220"
  15. style="margin-right: 10px;"
  16. >
  17. <div
  18. class="JKWTree-tree"
  19. style="height: 70vh;"
  20. >
  21. <h3>员工日工资查询</h3>
  22. <el-tree
  23. :data="treeData"
  24. highlight-current
  25. @node-click="handleNodeClick"
  26. />
  27. </div>
  28. </layout-sider>
  29. <el-container>
  30. <el-main>
  31. <!-- 按钮区域 -->
  32. <div class="gva-table-box">
  33. <div class="gva-btn-list">
  34. <el-row :span="6">
  35. <el-input v-model="searchInfo" placeholder="输入工单编号或产品名称" />
  36. </el-row>
  37. <el-button type="primary" :icon="Search" class="bt" @click="onSearch">搜索</el-button>
  38. <!-- <el-button type="primary" :icon="Refresh">重置</el-button> -->
  39. <!-- <el-button type="primary" :icon="Search" class="bt" @click="onposition">定位</el-button> -->
  40. <!-- <el-button type="primary" :icon="Search">查改</el-button> -->
  41. <el-button type="primary" class="bt" @click="handlePrint">员工计件明细</el-button>
  42. <div style="margin-left: auto;">
  43. <el-button type="primary" :icon="Download" class="bt" @click="exportExcel">导出到Excel(汇总)</el-button>
  44. <el-button type="primary" :icon="Download" class="bt" @click="exportExcel2">导出到Excel(明细)</el-button>
  45. </div>
  46. </div>
  47. <!-- 数据展示 -->
  48. <el-table ref="multipleTable" style="width: 100%;height: 40vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
  49. highlight-current-row="true" border @selection-change="handleSelectionChange" :show-overflow-tooltip="true"
  50. :row-style="{ height: '20px' }"
  51. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  52. :header-cell-style="{ padding: '0px' }"
  53. @row-click="ontable" @row-dblclick="doubleClick">
  54. <el-table-column type="selection" width="40" />
  55. <el-table-column
  56. v-for="column in tableCols1"
  57. :key="column.prop"
  58. :prop="column.prop"
  59. :label="column.label"
  60. :width="column.width"
  61. show-overflow-tooltip="true"
  62. sortable
  63. />
  64. </el-table>
  65. <!-- 分页 -->
  66. <!-- <div class="gva-pagination">
  67. <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
  68. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  69. @size-change="handleSizeChange" />
  70. </div> -->
  71. </div>
  72. <div class="gva-table-box">
  73. <!-- 数据展示 -->
  74. <el-table ref="multipleTable2" style="width: 100%;height: 40vh;" tooltip-effect="dark" :data="tableData2" row-key="ID"
  75. highlight-current-row="true" border
  76. :row-style="{ height: '20px' }"
  77. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  78. :header-cell-style="{ padding: '0px' }"
  79. @selection-change="handleSelectionChange"
  80. :show-overflow-tooltip="true"
  81. @row-dblclick="doubleClick">
  82. <el-table-column type="selection" width="40" />
  83. <el-table-column
  84. v-for="column in tableCols2"
  85. :key="column.prop"
  86. :prop="column.prop"
  87. :label="column.label"
  88. :width="column.width"
  89. show-overflow-tooltip="true"
  90. sortable
  91. />
  92. </el-table>
  93. <!-- 分页 -->
  94. <!-- <div class="gva-pagination">
  95. <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
  96. :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
  97. @size-change="handleSizeChange" />
  98. </div> -->
  99. </div>
  100. <!-- 弹出框 -->
  101. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '添加' : '修改'"
  102. destroy-on-close width="1200px">
  103. <!-- <el-scrollbar height="500px"> -->
  104. <el-form :model="formData" label-position="left" ref="elFormRef" :rules="rule">
  105. <el-row :gutter="20">
  106. <el-col :span="6">
  107. <el-form-item label="日期" prop="name">
  108. <el-row :gutter="20">
  109. <el-col :span="12">
  110. <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
  111. </el-col>
  112. </el-row>
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. <!-- 标题栏 -->
  117. <el-row :gutter="10">
  118. <el-col :span="3">
  119. <span>工单编号</span>
  120. </el-col>
  121. <el-col :span="3">
  122. <span>印件工序</span>
  123. </el-col>
  124. <el-col :span="3">
  125. <span>工序名称</span>
  126. </el-col>
  127. <el-col :span="9">
  128. <span>印件名称</span>
  129. </el-col>
  130. <el-col :span="2">
  131. <span>包装产量</span>
  132. </el-col>
  133. <el-col :span="2">
  134. <span>每箱数量</span>
  135. </el-col>
  136. <el-col :span="2">
  137. <span>零头</span>
  138. </el-col>
  139. </el-row>
  140. <!-- 员工1 -->
  141. <el-row :gutter="5" style="margin-top: 10px;">
  142. <el-col :span="3">
  143. <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
  144. </el-col>
  145. <el-col :span="3">
  146. <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
  147. </el-col>
  148. <el-col :span="3">
  149. <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
  150. </el-col>
  151. <el-col :span="9">
  152. <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
  153. </el-col>
  154. <el-col :span="2">
  155. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  156. </el-col>
  157. <el-col :span="2">
  158. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  159. </el-col>
  160. <el-col :span="2">
  161. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  162. </el-col>
  163. </el-row>
  164. <!-- 员工2 -->
  165. <el-row :gutter="5" style="margin-top: 10px;">
  166. <el-col :span="3">
  167. <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
  168. </el-col>
  169. <el-col :span="3">
  170. <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
  171. </el-col>
  172. <el-col :span="3">
  173. <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
  174. </el-col>
  175. <el-col :span="9">
  176. <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
  177. </el-col>
  178. <el-col :span="2">
  179. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  180. </el-col>
  181. <el-col :span="2">
  182. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  183. </el-col>
  184. <el-col :span="2">
  185. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  186. </el-col>
  187. </el-row>
  188. <!-- 员工3 -->
  189. <el-row :gutter="5" style="margin-top: 10px;">
  190. <el-col :span="3">
  191. <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
  192. </el-col>
  193. <el-col :span="3">
  194. <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
  195. </el-col>
  196. <el-col :span="3">
  197. <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
  198. </el-col>
  199. <el-col :span="9">
  200. <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
  201. </el-col>
  202. <el-col :span="2">
  203. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  204. </el-col>
  205. <el-col :span="2">
  206. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  207. </el-col>
  208. <el-col :span="2">
  209. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  210. </el-col>
  211. </el-row>
  212. <!-- 员工4 -->
  213. <el-row :gutter="5" style="margin-top: 10px;">
  214. <el-col :span="3">
  215. <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
  216. </el-col>
  217. <el-col :span="3">
  218. <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
  219. </el-col>
  220. <el-col :span="3">
  221. <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
  222. </el-col>
  223. <el-col :span="9">
  224. <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
  225. </el-col>
  226. <el-col :span="2">
  227. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  228. </el-col>
  229. <el-col :span="2">
  230. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  231. </el-col>
  232. <el-col :span="2">
  233. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  234. </el-col>
  235. </el-row>
  236. <!-- 员工5 -->
  237. <el-row :gutter="5" style="margin-top: 10px;">
  238. <el-col :span="3">
  239. <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
  240. </el-col>
  241. <el-col :span="3">
  242. <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
  243. </el-col>
  244. <el-col :span="3">
  245. <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
  246. </el-col>
  247. <el-col :span="9">
  248. <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
  249. </el-col>
  250. <el-col :span="2">
  251. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  252. </el-col>
  253. <el-col :span="2">
  254. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  255. </el-col>
  256. <el-col :span="2">
  257. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  258. </el-col>
  259. </el-row>
  260. <!-- 员工6 -->
  261. <el-row :gutter="5" style="margin-top: 10px;">
  262. <el-col :span="3">
  263. <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
  264. </el-col>
  265. <el-col :span="3">
  266. <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
  267. </el-col>
  268. <el-col :span="3">
  269. <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
  270. </el-col>
  271. <el-col :span="9">
  272. <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
  273. </el-col>
  274. <el-col :span="2">
  275. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  276. </el-col>
  277. <el-col :span="2">
  278. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  279. </el-col>
  280. <el-col :span="2">
  281. <el-input v-model="formData.image" :clearable="true" placeholder="是" />
  282. </el-col>
  283. </el-row>
  284. </el-form>
  285. <!-- </el-scrollbar> -->
  286. <template #footer>
  287. <div class="dialog-footer">
  288. <el-button @click="closeDialog">取 消</el-button>
  289. <el-button type="primary" @click="enterDialog">确 定</el-button>
  290. </div>
  291. </template>
  292. </el-dialog>
  293. <el-dialog v-model="positioningVisibleshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
  294. <el-card>
  295. <el-form-item label="员工编号" prop="name">
  296. <el-row :gutter="20">
  297. <el-col :span="12">
  298. <el-input v-model="positionvalue" :clearable="true" placeholder="ZT01733" />
  299. </el-col>
  300. </el-row>
  301. </el-form-item>
  302. </el-card>
  303. <el-button type="primary" @click="enterpositioning">确 定</el-button>
  304. </el-dialog>
  305. </el-main>
  306. </el-container>
  307. </el-container>
  308. <!-- 员工计件明细 -->
  309. <el-dialog
  310. v-model="dialogYgjjmx"
  311. title="员工计件明细"
  312. destroy-on-close
  313. >
  314. <Ygjjmx :ygbh="currentRow?.['bh']" />
  315. </el-dialog>
  316. </div>
  317. </template>
  318. <script setup>
  319. import {
  320. getList,
  321. getTab,
  322. dailygetTab,
  323. dailygetList,
  324. dailygetAllList,
  325. dailygetDetail,
  326. dailysearch
  327. } from '@/api/jixiaoguanli/jitairibaobiao'
  328. // 全量引入格式化工具 请按需保留
  329. import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
  330. import { ElMessage, ElMessageBox } from 'element-plus'
  331. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  332. import { ref, reactive, onMounted, onBeforeMount } from 'vue'
  333. import { getPackingSideTable, getPackingTable } from '@/api/mes_api_gty/myapi'
  334. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  335. import Ygjjmx from './printYgjjmx.vue'
  336. import * as XLSX from "xlsx";
  337. import { useUserStore } from '@/pinia/modules/user'
  338. const userStore = useUserStore()
  339. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  340. defineOptions({
  341. name: '06-packingDocuments'
  342. })
  343. const tableCols1 = [
  344. { label: '员工编号', prop: 'bh', width: '105' },
  345. { label: '员工姓名', prop: '员工姓名', width: '105' },
  346. { label: '日期', prop: 'sczl_rq', width: '120' },
  347. { label: '计件工资', prop: '计件工资', width: '105' },
  348. { label: '加班工资', prop: '加班工资', width: '105' },
  349. { label: '计时时数', prop: '计时时数', width: '105' },
  350. { label: '计时工资', prop: '计时工资', width: '135' },
  351. { label: '日工资合计', prop: '日工资合计', width: '135' },
  352. ]
  353. const tableCols2 = [
  354. { label: '日期', prop: 'sczl_rq', width: '105' },
  355. { label: '工单编号', prop: 'sczl_gdbh', width: '105' },
  356. { label: '产品名称', prop: 'Gd_cpmc', width: '120' },
  357. { label: '印件及工序', prop: 'sczl_type', width: '120' },
  358. { label: '机台编号', prop: 'sczl_jtbh', width: '105' },
  359. { label: '班组车头产量', prop: '班组车头产量', width: '135' },
  360. { label: '班组换算产量', prop: '班组换算产量', width: '135' },
  361. { label: '工序难度系数', prop: '工序难度系数', width: '135' },
  362. { label: '个人计件工资', prop: '个人计件工资', width: '135' },
  363. { label: '个人加班工资', prop: '个人加班工资', width: '135' },
  364. { label: '装版工时', prop: '装版工时', width: '120' },
  365. { label: '保养工时', prop: '保养工时', width: '105' },
  366. { label: '打样工时', prop: '打样工时', width: '105' },
  367. { label: '异常停机工时', prop: '异常停机工时', width: '145' },
  368. { label: '车头产量占用机时', prop: '车头产量占用机时', width: '175' },
  369. { label: '日定额', prop: '日定额', width: '135' },
  370. { label: '达标定额', prop: '达标定额', width: '105' },
  371. { label: '千件工价', prop: '千件工价', width: '105' },
  372. { label: '补产标准', prop: '补产标准', width: '120' },
  373. { label: '员工编号', prop: 'bh', width: '105' },
  374. { label: '姓名', prop: 'xm', width: '105' },
  375. { label: '比例', prop: 'Rate', width: '105' },
  376. { label: '班组换算产量', prop: '班组换算产量', width: '135' },
  377. { label: '工序难度系数', prop: '工序难度系数', width: '135' },
  378. ]
  379. // 侧边栏数据请求
  380. const treeData = reactive([]);
  381. const multipleTable=ref()
  382. const getTabdata = async () => {
  383. //接口调用函数
  384. const response = await dailygetTab();
  385. const transformedData = response.data.map(item => ({
  386. label: `${item.label}`,
  387. children: item.children.map(sysItem => ({
  388. label: `${sysItem.label}`,
  389. params: {
  390. date: item.label,
  391. sys_id: sysItem.label,
  392. total:'',
  393. },
  394. })),
  395. }));
  396. treeData.splice(0, treeData.length, ...transformedData);
  397. }
  398. getTabdata();
  399. // 自动化生成的字典(可能为空)以及字段
  400. const formData = ref({
  401. id: '',
  402. name: '',
  403. date: '',
  404. group: '',
  405. packingOutput: '',
  406. reworkOutput: '',
  407. pieceOutput: '',
  408. order: '',
  409. user: '',
  410. createTime: '',
  411. updateTime: '',
  412. uniqid: '',
  413. })
  414. // 验证规则
  415. const rule = reactive({
  416. })
  417. const elFormRef = ref()
  418. const elSearchFormRef = ref()
  419. // =========== 表格控制部分 ===========
  420. const tableData = reactive([])
  421. const tableData2 = reactive([])
  422. const detailData = reactive([])
  423. const total = ref(0)
  424. const page = ref(1)
  425. const limit = ref(10)
  426. const searchInfo = ref('')
  427. const params = {
  428. date: '',
  429. sys_id: '',
  430. page: page.value.toString(),
  431. limit: limit.value.toString(),
  432. }
  433. // 分页设置
  434. const handleSizeChange = (val) => {
  435. limit.value = val;
  436. params.limit = val.toString();
  437. getTableData();
  438. }
  439. // 页面跳转
  440. const handleCurrentChange = (val) => {
  441. page.value = val
  442. params.page = val.toString();
  443. getTableData()
  444. }
  445. // 查询
  446. const getTableData = async () => {
  447. const response = await dailygetList({
  448. date: params.date, department: params.sys_id,});
  449. // console.log(response)
  450. if (response.code === 0) {
  451. const originalData = response.data;
  452. const summaryData = generateSummaryData(originalData);
  453. // 将合计数据插入到原始数据中
  454. const combinedData = [];
  455. originalData.forEach((item, index) => {
  456. combinedData.push(item);
  457. const nextItem = originalData[index + 1];
  458. if (nextItem && nextItem['员工姓名'] !== item['员工姓名']) {
  459. // 如果下一个员工姓名与当前不同,插入合计数据
  460. const currentSummary = summaryData.shift();
  461. combinedData.push(currentSummary);
  462. }
  463. });
  464. // console.log(combinedData)
  465. // 更新表格数据
  466. tableData.splice(0, tableData.length, ...combinedData);
  467. }
  468. }
  469. const generateSummaryData = (data) => {
  470. const summaryData = [];
  471. let currentName = null;
  472. let currentSummary = null;
  473. data.forEach((item) => {
  474. const name = item['员工姓名'].trim(); // 获取员工姓名并去除空格
  475. if (name !== currentName) {
  476. // 如果员工姓名发生改变,说明需要插入合计数据
  477. if (currentSummary) {
  478. // 将上一个员工的合计数据插入到数组中
  479. summaryData.push(currentSummary);
  480. }
  481. // 创建新的合计数据
  482. currentSummary = {
  483. '员工姓名': name,
  484. '日期': 0,
  485. '计件工资': 0,
  486. '加班工资': 0,
  487. '计时时数': 0,
  488. '计时工资': 0,
  489. '日工资合计': 0
  490. };
  491. currentName = name;
  492. }
  493. // 更新合计数据
  494. currentSummary['日期']++;
  495. currentSummary['计件工资'] += parseFloat(item['计件工资']);
  496. currentSummary['加班工资'] += parseFloat(item['加班工资']);
  497. currentSummary['计时时数'] += parseFloat(item['计时时数']);
  498. currentSummary['计时工资'] += parseFloat(item['计时工资']);
  499. currentSummary['日工资合计'] += parseFloat(item['日工资合计']);
  500. currentSummary['员工姓名']='合计('+currentSummary['日期']+'天)';
  501. });
  502. // 将最后一个员工的合计数据插入到数组中
  503. if (currentSummary) {
  504. summaryData.push(currentSummary);
  505. }
  506. // 将日期填充到表格中
  507. summaryData.forEach((summary) => {
  508. summary['计件工资'] = summary['计件工资'].toFixed(2); // 保留两位小数
  509. summary['加班工资'] = summary['加班工资'].toFixed(2);
  510. summary['计时时数'] = summary['计时时数'].toFixed(2);
  511. summary['计时工资'] = summary['计时工资'].toFixed(2);
  512. summary['日工资合计'] = summary['日工资合计'].toFixed(2);
  513. });
  514. return summaryData;
  515. };
  516. const handleNodeClick = (node, check) => {
  517. //存放当前节点的nodeId
  518. if (node.params) {
  519. params.date = node.params.date;
  520. params.sys_id = node.params.sys_id;
  521. total.value = node.params.total;
  522. getTableData();
  523. }
  524. }
  525. // 定位
  526. function onposition() {
  527. positioningVisibleshow.value=true
  528. }
  529. const enterpositioning = async () => {
  530. let parts = params.date.split('-')
  531. // # 截取第一个"-"之前的内容并赋值给新变量1
  532. let new_variable1 = parts[0]
  533. // # 截取第一个"-"之后到第二个"-"之前的内容并赋值给新变量2
  534. let new_variable2 = parts[1]
  535. Getlocate(new_variable1+new_variable2)
  536. positioningVisibleshow.value=false
  537. }
  538. let positionvalue=ref()
  539. const Getlocate = async (value) => {
  540. // const response = await locate(locatevalue);
  541. // console.log(locatevalue)
  542. // console.log(response)
  543. // if (response.code === 0) {
  544. // tableData.splice(0, tableData.length, ...response.data.rows);
  545. // }
  546. const response = await dailysearch({
  547. date: value,
  548. search:positionvalue.value
  549. })
  550. if (response.code === 0) {
  551. tableData.splice(0, tableData.length, ...response.data)
  552. }
  553. }
  554. // 搜索
  555. function onSearch() {
  556. let parts = params.date.split('-')
  557. // # 截取第一个"-"之前的内容并赋值给新变量1
  558. let new_variable1 = parts[0]
  559. // # 截取第一个"-"之后到第二个"-"之前的内容并赋值给新变量2
  560. let new_variable2 = parts[1]
  561. Getlocate(new_variable1+new_variable2)
  562. // positioningVisibleshow.value=false
  563. }
  564. // ============== 表格控制部分结束 ===============
  565. // 获取需要的字典 可能为空 按需保留
  566. const setOptions = async () => {
  567. }
  568. // 获取需要的字典 可能为空 按需保留
  569. setOptions()
  570. // 多选数据
  571. const multipleSelection = ref([])
  572. // 多选
  573. const handleSelectionChange = (val) => {
  574. // multipleSelection.value = val
  575. }
  576. // 批量删除控制标记
  577. const deleteVisible = ref(false)
  578. // 多选删除
  579. const onDelete = async () => {
  580. const ids = []
  581. if (multipleSelection.value.length === 0) {
  582. ElMessage({
  583. type: 'warning',
  584. message: '请选择要删除的数据'
  585. })
  586. return
  587. }
  588. multipleSelection.value &&
  589. multipleSelection.value.map(item => {
  590. ids.push(item.ID)
  591. })
  592. const res = await deleteCompanyByIds({ ids })
  593. if (res.code === 0) {
  594. ElMessage({
  595. type: 'success',
  596. message: '删除成功'
  597. })
  598. if (tableData.value.length === ids.length && page.value > 1) {
  599. page.value--
  600. }
  601. deleteVisible.value = false
  602. getTableData()
  603. }
  604. }
  605. // 行为控制标记(弹窗内部需要增还是改)
  606. const type = ref('')
  607. // 更新行
  608. const updateCompanyFunc = async (row) => {
  609. const res = await findCompany({ ID: row.ID })
  610. type.value = 'update'
  611. if (res.code === 0) {
  612. formData.value = res.data.recompany
  613. dialogFormVisible.value = true
  614. }
  615. }
  616. // 弹窗控制标记
  617. const dialogFormVisible = ref(false)
  618. const positioningVisibleshow = ref(false)
  619. // 打开弹窗
  620. const openDialog = () => {
  621. type.value = 'create'
  622. dialogFormVisible.value = true
  623. }
  624. // 关闭弹窗
  625. const closeDialog = () => {
  626. dialogFormVisible.value = false
  627. formData.value = {
  628. address: '',
  629. image: '',
  630. name: '',
  631. }
  632. }
  633. // 弹窗确定
  634. const enterDialog = async () => {
  635. elFormRef.value?.validate(async (valid) => {
  636. if (!valid) return
  637. let res
  638. switch (type.value) {
  639. case 'create':
  640. res = await createCompany(formData.value)
  641. break
  642. case 'update':
  643. res = await updateCompany(formData.value)
  644. break
  645. default:
  646. res = await createCompany(formData.value)
  647. break
  648. }
  649. if (res.code === 0) {
  650. ElMessage({
  651. type: 'success',
  652. message: '创建/更改成功'
  653. })
  654. closeDialog()
  655. getTableData()
  656. }
  657. })
  658. }
  659. // 单击表格操作
  660. function ontable(row, column, event) {
  661. currentRow.value = row
  662. let parts = params.date.split('-')
  663. // # 截取第一个"-"之前的内容并赋值给新变量1
  664. let new_variable1 = parts[0]
  665. // # 截取第一个"-"之后到第二个"-"之前的内容并赋值给新变量2
  666. let new_variable2 = parts[1]
  667. Getundertable(new_variable1,row.bh)
  668. }
  669. //获取下列表
  670. const Getundertable = (date,bh) => {
  671. if(bh == undefined) return
  672. dailygetAllList({date:date,code:bh}).then(response=>{
  673. if(response.code==0){
  674. tableData2.splice(0, tableData2.length, ...response.data);
  675. // console.log(response.data.num)
  676. // const rowIndex = tableData.findIndex(row => row.UniqId === lastCellValue);
  677. // console.log(rowIndex)
  678. // tableData[rowIndex].sczl_废品率系数 = response.data.num;
  679. }
  680. })
  681. // console.log(response)
  682. // const rowIndex = tableData.findIndex(row => row.UniqId === 123);
  683. }
  684. // 双击表格操作
  685. function doubleClick(row, column, event) {
  686. // updateCompanyFunc(row);
  687. type.value = 'update';
  688. // dialogFormVisible.value = true
  689. }
  690. // 导出excel
  691. function exportExcel() {
  692. if(tableData.length<1){
  693. ElMessage({
  694. type: 'error',
  695. message: '请确认上方表格内是否存在内容'
  696. })
  697. }else{
  698. exportExcelFile(tableData,tableCols1)
  699. }
  700. };
  701. function exportExcel2() {
  702. if(tableData2.length<1){
  703. ElMessage({
  704. type: 'error',
  705. message: '请确认上方表格内是否存在内容'
  706. })
  707. }else{
  708. exportExcelFile(tableData2,tableCols2)
  709. }
  710. };
  711. const exportExcelFile = (tableData, tableCols) => {
  712. const data = tableData.map(row => {
  713. const rowData = {};
  714. tableCols.forEach(column => {
  715. rowData[column.label] = row[column.prop];
  716. });
  717. return rowData;
  718. });
  719. const worksheet = XLSX.utils.json_to_sheet(data);
  720. const workbook = XLSX.utils.book_new();
  721. XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
  722. XLSX.writeFile(workbook, 'exported_table.xlsx');
  723. };
  724. const currentRow = ref()
  725. const dialogYgjjmx = ref(false)
  726. function handlePrint() {
  727. dialogYgjjmx.value = true
  728. }
  729. // 生命周期钩子
  730. onMounted(async () => {
  731. });
  732. </script>
  733. <style>
  734. .JKWTree-container {
  735. display: flex;
  736. }
  737. .JKWTree-tree {
  738. width: 300px;
  739. background-color: #fff;
  740. padding: 10px;
  741. margin-right: 20px;
  742. }
  743. .JKWTree-tree h3 {
  744. font-size: 15px;
  745. font-weight: 700;
  746. margin: 10px 0;
  747. }
  748. .JKWTree-content {
  749. flex: 1;
  750. }
  751. /* 选中某行时的背景色*/
  752. .el-table__body tr.current-row>td {
  753. background: #ff80ff !important;
  754. /* 背景颜色 */
  755. }
  756. .bt {
  757. margin-left: 2px !important;
  758. padding: 3px !important;
  759. font-size: 12px;
  760. }
  761. </style>