Index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div class="app-container">
  3. <!--查询表单-->
  4. <el-card class="operate-container" shadow="never">
  5. <el-form :inline="true" class="demo-form-inline">
  6. <el-form-item label="所属产线">
  7. <el-select
  8. v-model="zoneId"
  9. clearable
  10. placeholder="请选择"
  11. style="width: 100%"
  12. @change="getResourceList()"
  13. >
  14. <el-option
  15. v-for="(item, index) in zoneList"
  16. :key="index"
  17. :label="item.name"
  18. :value="item.value"
  19. />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="任务类型">
  23. <el-select
  24. v-model="taskType"
  25. clearable
  26. placeholder="请选择"
  27. style="width: 100%"
  28. @change="getResourceList()"
  29. >
  30. <el-option
  31. v-for="(item, index) in taskTypeList"
  32. :key="index"
  33. :label="item.name"
  34. :value="item.key"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="选择设备">
  39. <el-select
  40. v-model="searchObj.resourceId"
  41. clearable
  42. placeholder="请选择"
  43. style="width: 100%"
  44. >
  45. <el-option
  46. v-for="(item, index) in resourceIds"
  47. :key="index"
  48. :label="item.name"
  49. :value="item.id"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="生产时间">
  54. <el-date-picker
  55. v-model="searchObj.startDate"
  56. placeholder="开始时间"
  57. value-format="yyyy-MM-dd"
  58. />
  59. </el-form-item>
  60. <el-form-item label="-">
  61. <el-date-picker
  62. v-model="searchObj.endDate"
  63. placeholder="结束时间"
  64. value-format="yyyy-MM-dd"
  65. />
  66. </el-form-item>
  67. <el-form-item label="生产月份">
  68. <el-date-picker
  69. v-model="searchObj.month"
  70. type="month"
  71. placeholder="选择月"
  72. value-format="yyyy-MM"
  73. >
  74. </el-date-picker>
  75. </el-form-item>
  76. <el-form-item label="生产年份">
  77. <el-date-picker
  78. v-model="searchObj.years"
  79. type="year"
  80. placeholder="选择年"
  81. value-format="yyyy"
  82. >
  83. </el-date-picker>
  84. </el-form-item>
  85. <el-button type="primary" icon="el-icon-search" @click="fetch()"
  86. >查询</el-button
  87. >
  88. <el-button type="default" @click="resetData()">清空</el-button>
  89. <el-button type="primary" icon="el-icon-download" @click="exportData()" v-show="false" >导出</el-button>
  90. </el-form>
  91. </el-card>
  92. <!-- 列表数据 -->
  93. <el-table
  94. :key="tableKey"
  95. ref="table"
  96. :data="tableData"
  97. border
  98. fit
  99. style="width: 100%"
  100. @selection-change="onSelectChange"
  101. >
  102. <el-table-column
  103. :label="$t('common.serialNo')"
  104. width="55px"
  105. align="center"
  106. >
  107. <template slot-scope="scope">
  108. {{ (page - 1) * limit + scope.$index + 1 }}
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="设备资源生产表" :resizable="false" align="center">
  112. <!--产线-->
  113. <el-table-column
  114. prop="zoneName"
  115. :label="$t('statisticalAnalysis.table.deviceResource.zoneName')"
  116. :show-overflow-tooltip="true"
  117. >
  118. </el-table-column>
  119. <!--分配设备-->
  120. <el-table-column
  121. prop="resourceName"
  122. :label="$t('statisticalAnalysis.table.deviceResource.resourceName')"
  123. :show-overflow-tooltip="true"
  124. >
  125. </el-table-column>
  126. <!--总数量-->
  127. <el-table-column
  128. prop="totalNum"
  129. :label="$t('statisticalAnalysis.table.deviceResource.totalNum')"
  130. :show-overflow-tooltip="true"
  131. >
  132. </el-table-column>
  133. <!--日期-->
  134. <el-table-column
  135. prop="time"
  136. :label="$t('statisticalAnalysis.table.deviceResource.time')"
  137. :show-overflow-tooltip="true"
  138. >
  139. </el-table-column>
  140. <!--理论加工周期-->
  141. <el-table-column
  142. prop="totalExpectTime"
  143. :label="$t('statisticalAnalysis.table.deviceResource.totalExpectTime')"
  144. :show-overflow-tooltip="true"
  145. >
  146. </el-table-column>
  147. <!--实际加工周期-->
  148. <el-table-column
  149. prop="totalRealTime"
  150. :label="$t('statisticalAnalysis.table.deviceResource.totalRealTime')"
  151. :show-overflow-tooltip="true"
  152. >
  153. </el-table-column>
  154. <!--平均理论加工周期-->
  155. <el-table-column
  156. prop="avgExpectTime"
  157. width="150px"
  158. :label="$t('statisticalAnalysis.table.deviceResource.avgExpectTime')"
  159. :show-overflow-tooltip="true"
  160. >
  161. </el-table-column>
  162. <!--平均实际加工周期-->
  163. <el-table-column
  164. prop="avgRealTime"
  165. width="150px"
  166. :label="$t('statisticalAnalysis.table.deviceResource.avgRealTime')"
  167. :show-overflow-tooltip="true"
  168. >
  169. </el-table-column>
  170. <!--操作-->
  171. <el-table-column label="操作" width="100" align="center">
  172. <template slot-scope="scope">
  173. <el-button type="text" @click="fetchDataById(scope.row)"
  174. >查看详情</el-button
  175. >
  176. </template>
  177. </el-table-column>
  178. </el-table-column>
  179. </el-table>
  180. <p style="color: #E96767;size: 10px;float: right">生产总数:{{totalNum}}</p>
  181. <!-- 分页组件 -->
  182. <el-pagination
  183. :current-page="page"
  184. :total="total"
  185. :page-size="limit"
  186. :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
  187. style="padding: 30px 0; text-align: center"
  188. layout="total, sizes, prev, pager, next, jumper"
  189. @size-change="changePageSize"
  190. @current-change="changeCurrentPage"
  191. />
  192. <el-dialog title="产品加工详情" :close-on-click-modal="false" :visible.sync="dialogVisible" style="width: 110%; margin-top: 20px">
  193. <el-table
  194. :key="tableKey"
  195. ref="table"
  196. :data="formData"
  197. border
  198. fit
  199. style="width: 100%"
  200. >
  201. <!--订单号-->
  202. <el-table-column
  203. prop="orderNo"
  204. :label="$t('statisticalAnalysis.table.deviceResourceDetail.orderNo')"
  205. :show-overflow-tooltip="true"
  206. width="140"
  207. >
  208. </el-table-column>
  209. <!--产线名称-->
  210. <el-table-column
  211. prop="zoneName"
  212. :label="$t('statisticalAnalysis.table.deviceResourceDetail.zoneName')"
  213. :show-overflow-tooltip="true"
  214. width="145"
  215. >
  216. </el-table-column>
  217. <!--分配设备名称-->
  218. <el-table-column
  219. prop="resourceName"
  220. :label="$t('statisticalAnalysis.table.deviceResourceDetail.resourceName')"
  221. :show-overflow-tooltip="true"
  222. width="160"
  223. >
  224. </el-table-column>
  225. <!--产品名称-->
  226. <el-table-column
  227. prop="bomName"
  228. :label="$t('statisticalAnalysis.table.deviceResourceDetail.bomName')"
  229. :show-overflow-tooltip="true"
  230. width="130"
  231. >
  232. </el-table-column>
  233. <!--工序-->
  234. <el-table-column
  235. prop="procedureNo"
  236. :label="$t('statisticalAnalysis.table.deviceResourceDetail.procedureNo')"
  237. :show-overflow-tooltip="true"
  238. >
  239. </el-table-column>
  240. <!--开始时间-->
  241. <el-table-column
  242. prop="startTime"
  243. :label="$t('statisticalAnalysis.table.deviceResourceDetail.startTime')"
  244. :show-overflow-tooltip="true"
  245. width="160"
  246. >
  247. </el-table-column>
  248. <!--结束时间-->
  249. <el-table-column
  250. prop="endTime"
  251. :label="$t('statisticalAnalysis.table.deviceResourceDetail.endTime')"
  252. :show-overflow-tooltip="true"
  253. width="160"
  254. >
  255. </el-table-column>
  256. </el-table>
  257. <!-- 分页组件 -->
  258. <el-pagination
  259. :current-page="page2"
  260. :total="total2"
  261. :page-size="limit2"
  262. :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
  263. style="padding: 30px 0; text-align: center"
  264. layout="total, sizes, prev, pager, next, jumper"
  265. @size-change="changePageSize2"
  266. @current-change="changeCurrentPage2"
  267. />
  268. </el-dialog>
  269. </div>
  270. </template>
  271. <script>
  272. // 【产品加工汇总】-API
  273. import productlineAvailabilityApi from "@/api/statisticalAnalysis/productlineAvailability";
  274. // 【弹出框】elementui组件
  275. import elDragDialog from "@/directive/el-drag-dialog";
  276. import Pagination from "@/components/Pagination";
  277. import areaMgrApi from "@/api/resourceProductMgr/areaMgr";
  278. export default {
  279. name: "productStatistics",
  280. directives: {
  281. elDragDialog,
  282. },
  283. components: {},
  284. data() {
  285. return {
  286. tableData: [], // 讲师列表
  287. formData: [],
  288. total: 0, // 总记录数
  289. page: 1, // 当前页码
  290. limit: 10, // 每页记录数
  291. page2: 1, // 当前页码
  292. limit2: 10, // 每页记录数
  293. total2: 0, // 总记录数
  294. searchObj: {}, // 查询条件
  295. dialogVisible: false, //是否弹框
  296. zoneList: [],
  297. row2: {},
  298. totalNum: 0
  299. };
  300. },
  301. computed: {},
  302. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  303. created() {
  304. // 加载列表数据
  305. this.fetch();
  306. this.getZoneList();
  307. },
  308. watch: {
  309. loadingId: {
  310. handler(val, oldVal) {
  311. // 加载列表数据
  312. this.fetch();
  313. },
  314. },
  315. loadingDate: {
  316. handler(val, oldVal) {
  317. // 加载列表数据
  318. this.fetch();
  319. },
  320. },
  321. },
  322. mounted() {},
  323. methods: {
  324. view(row) {
  325. this.$refs.view.setOperatorDetailPerformance(row);
  326. this.operatorViewVisible = true;
  327. },
  328. fetch() {
  329. let index = 0;
  330. if(this.searchObj.startDate) index++;
  331. if(this.searchObj.month) index++;
  332. if(this.searchObj.years) index++;
  333. if(index>1) {
  334. this.$message({
  335. message: "时间,月份,年份只能选择一个",
  336. type: "warning"
  337. })
  338. return
  339. }
  340. this.tableKey = !this.tableKey;
  341. productlineAvailabilityApi
  342. .deviceResourceSum(this.page, this.limit, this.searchObj)
  343. .then((response) => {
  344. const res = response.data;
  345. this.tableData = (res.data || []).records;
  346. this.totalNum = 0
  347. if(this.tableData){
  348. this.tableData.forEach(item => {
  349. this.totalNum += Number(item.totalNum)
  350. })
  351. }
  352. this.total = (res.data || []).total;
  353. });
  354. },
  355. //根据id查询
  356. fetchDataById(row) {
  357. //弹出框
  358. this.row2 = row
  359. this.dialogVisible = true;
  360. const obj = {
  361. resourceId: row.resourceId,
  362. zoneId: row.zoneId,
  363. startDate: this.searchObj.startDate,
  364. endDate: this.searchObj.endDate,
  365. month: this.searchObj.month,
  366. years: this.searchObj.years
  367. }
  368. this.tableKey = !this.tableKey;
  369. productlineAvailabilityApi
  370. .deviceResourceDetail(this.page2,this.limit2,obj)
  371. .then((response) => {
  372. const res = response.data;
  373. this.formData = (res.data || []).records;
  374. this.total2 = (res.data || []).total;
  375. });
  376. },
  377. // 每页记录数改变,size:回调参数,表示当前选中的“每页条数”
  378. changePageSize(size) {
  379. this.limit = size;
  380. this.fetch();
  381. },
  382. // 改变页码,page:回调参数,表示当前选中的“页码”
  383. changeCurrentPage(page) {
  384. this.page = page;
  385. this.fetch();
  386. },
  387. changePageSize2(size) {
  388. this.limit2 = size;
  389. console.log("执行")
  390. this.fetchDataById(this.row2);
  391. },
  392. changeCurrentPage2(page) {
  393. this.page2 = page;
  394. console.log("执行")
  395. this.fetchDataById(this.row2);
  396. },
  397. //清空
  398. resetData() {
  399. this.searchObj = {};
  400. this.fetch();
  401. },
  402. cellClick(row, column) {
  403. if (column["columnKey"] === "operation") {
  404. return;
  405. }
  406. let flag = false;
  407. this.selection.forEach((item) => {
  408. if (item.id === row.id) {
  409. flag = true;
  410. this.$refs.table.toggleRowSelection(row);
  411. }
  412. });
  413. if (!flag) {
  414. this.$refs.table.toggleRowSelection(row, true);
  415. }
  416. },
  417. onSelectChange(selection) {
  418. this.selection = selection;
  419. },
  420. getZoneList() {
  421. areaMgrApi.getList({ status: 1 }).then((res) => {
  422. res = res.data;
  423. if (res.isSuccess) {
  424. if(res.data){
  425. this.zoneList = res.data.filter(item => item.name.indexOf('保障') ==-1)
  426. }
  427. }
  428. });
  429. },
  430. //导出
  431. exportData() {
  432. productlineAvailabilityApi.exportTaskResourceSum(this.searchObj).then((res) => {
  433. if (!res) return;
  434. const blob = new Blob([res.data], {
  435. type: "application/vnd.ms-excel;",
  436. });
  437. const a = document.createElement("a");
  438. // 生成文件路径
  439. let href = window.URL.createObjectURL(blob);
  440. a.href = href;
  441. // 文件名中有中文 则对文件名进行转码
  442. a.download = decodeURIComponent("任务资源汇总导出");
  443. // 利用a标签做下载
  444. document.body.appendChild(a);
  445. a.click();
  446. document.body.removeChild(a);
  447. window.URL.revokeObjectURL(href);
  448. this.allloading = false;
  449. });
  450. },
  451. //
  452. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  453. if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2) {
  454. const _row = this.flitterData(this.formData).one[rowIndex];
  455. const _col = _row > 0 ? 1 : 0;
  456. return {
  457. rowspan: _row,
  458. colspan: _col,
  459. };
  460. }
  461. },
  462. /**合并表格的第一列,处理表格数据 */
  463. flitterData(arr) {
  464. let spanOneArr = [];
  465. let concatOne = 0;
  466. arr.forEach((item, index) => {
  467. if (index === 0) {
  468. spanOneArr.push(1);
  469. } else {
  470. //注意这里的quarterly是表格绑定的字段,根据自己的需求来改
  471. if (item.quarterly === arr[index - 1].quarterly) {
  472. //第一列需合并相同内容的判断条件
  473. spanOneArr[concatOne] += 1;
  474. spanOneArr.push(0);
  475. } else {
  476. spanOneArr.push(1);
  477. concatOne = index;
  478. }
  479. }
  480. });
  481. return {
  482. one: spanOneArr,
  483. };
  484. }
  485. },
  486. };
  487. </script>
  488. <style lang="scss" scoped>
  489. .rowBtn {
  490. margin: 0 5px;
  491. color: #1890ff;
  492. }
  493. .rowBtn:hover {
  494. opacity: 0.7;
  495. }
  496. </style>