yuangongrigongzi.vue 28 KB

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