| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- <template>
- <div>
- <ele-pro-table
- ref="table"
- :columns="columns"
- height="calc(100vh - 280px)"
- width="100%"
- :datasource="datasource"
- :selection.sync="selection"
- @selection-change="handleSelectionChange"
- @cell-click="cellClick"
- highlight-current-row
- @select="cellClick"
- :need-page="false"
- @sort-change="onSortChange"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- >
- <!-- <template v-slot:toolbar>
- <div class="rx-bc">
- <div class="c_title">工单列表 </div>
- <div>
- <el-input
- style="width: 180px"
- clearable
- v-model="code"
- placeholder="请输入工单号"
- />
- <el-button size="mini" type="primary" style="margin: 0 5px" @click="handleSearch">查询</el-button>
- </div>
- </div>
- </template> -->
- <template v-slot:code="{ row }">
- <el-link type="primary" @click="handRoute(row)" :underline="false">{{
- row.code
- }}</el-link>
- </template>
- <template v-slot:singleReport="{ row }">
- <el-tag size="mini">
- {{ row.singleReport == 1 ? '单个报工' : '批量报工' }}</el-tag
- >
- </template>
- <template v-slot:taskName="{ row }">
- <span> {{ row.taskName }}</span>
- </template>
- <template v-slot:status="{ row }">
- <span> {{ sumStatus(row) }}</span>
- </template>
- <template v-slot:formingNum="{ row }">
- <span> {{ row.formingNum }} {{ row.unit }} </span>
- </template>
- <template v-slot:formingWeight="{ row }">
- <span> {{ row.formingWeight }} {{ row.weightUnit }} </span>
- </template>
- </ele-pro-table>
- <!-- //工单列表 -->
- <routings
- v-if="routingShow"
- :routeObj="routeObj"
- @closeRoute="closeRoute"
- ></routings>
- </div>
- </template>
- <script>
- import { workorderPage2 } from '@/api/produce/workOrder.js';
- import routings from './routings.vue';
- import { isFullscreen } from 'ele-admin';
- import tableColumnsMixin from '@/mixins/tableColumnsMixin';
- export default {
- components: { routings },
- mixins: [tableColumnsMixin],
- data() {
- return {
- loading: false,
- selection: [],
- routeObj: {},
- routingShow: false,
- code: '',
- internalIsFullscreen: isFullscreen(), // 初始值
- cacheKeyUrl: 'mes-145878-mes-produce',
- columnsVersion: 0
- };
- },
- computed: {
- // 表格列配置
- columns() {
- let columnsVersion=this.columnsVersion;
- return [
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- fixed: true
- },
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'batchNo',
- label: '批次号',
- align: 'center'
- },
- {
- prop: 'code',
- slot: 'code',
- label: '生产工单号',
- align: 'center',
- minWidth: '160'
- },
- {
- prop: 'productCode',
- label: '编码',
- align: 'center',
- minWidth: '160',
- showOverflowTooltip: true
- },
- {
- prop: 'productName',
- label: '名称',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'singleReport',
- slot: 'singleReport',
- label: '报工类型',
- align: 'center',
- filters: [
- { text: '单个报工', value: 1 },
- { text: '批量报工', value: 0 }
- ],
- filterMethod: this.filterMethod,
- width: 100
- },
- {
- prop: 'model',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'productionCodes',
- label: '生产编号',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true
- },
- {
- prop: 'brandNo',
- label: '牌号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'priority',
- label: '优先级',
- align: 'center',
- minWidth: 120
- },
- {
- prop: 'formingNum',
- label: '要求生产数量',
- align: 'center',
- slot: 'formingNum',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'formingWeight',
- label: '要求生产重量',
- slot: 'formingWeight',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'formedNum',
- label: '已生产数量',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'formedWeight',
- label: '已生产重量',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- slot: 'taskName',
- prop: 'taskName',
- label: '工序进度',
- align: 'center',
- showOverflowTooltip: true,
- sortable: 'custom',
- minWidth: 110
- },
- {
- slot: 'status',
- prop: 'status',
- label: '最新工单状态',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'planStartTime',
- label: '计划开始时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'planCompleteTime',
- label: '计划结束时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'startTime',
- label: '实际开始时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- }
- ];
- },
- taskObj() {
- return this.$store.state.user.taskObj;
- },
- current() {
- console.log(this.$store.state.user, 'this.$store.state.user');
- return this.$store.state.user.currentObj.id;
- }
- },
- watch: {
- taskObj: {
- handler(val) {
- this.reload();
- },
- // immediate: true,
- deep: true
- },
- current: {
- handler(val) {
- this.reload();
- },
- // immediate: true,
- deep: true
- }
- },
- created() {},
- mounted() {
- // 添加窗口resize事件监听器
- window.addEventListener('resize', this.handleResize);
- },
- beforeDestroy() {
- // 组件销毁前移除事件监听器,防止内存泄漏
- window.removeEventListener('resize', this.handleResize);
- },
- methods: {
- filterMethod(value, row, column) {
- if (value == row.singleReport) {
- return row;
- }
- },
- sumStatus(row) {
- if (row.reportStatus === 1) {
- return '已报工';
- }
- if (row.feedStatus === 1) {
- return '已投料';
- }
- // {{ row.reportStatus }} {{ row.feedStatus }}
- },
- /* 表格数据源 */
- datasource({ page, where }) {
- if (!this.taskObj?.id) {
- return [];
- }
- return workorderPage2({
- pageNum: page,
- size: 1000,
- workOrderId: this.$route.query.workOrderId
- ? this.$route.query.workOrderId
- : null,
- taskId: this.taskObj && this.taskObj.id,
- deviceId: this.current && this.current.deviceId,
- keyWord: this.keyWord,
- taskName: this.taskName,
- ...where
- });
- },
- onSortChange(e) {
- console.log(e);
- let sort = {
- orderBy: e.order,
- sortName: e.prop
- };
- this.where = sort;
- this.reload();
- },
- handleSearch(obj) {
- this.keyWord = obj.keyWord;
- this.taskName = obj.taskName;
- this.reload();
- },
- /* 刷新表格 */
- reload(where) {
- this.$nextTick(() => {
- this.$refs.table.reload({ page: 1, where });
- });
- },
- handleSelectionChange(val) {
- let initReportValue = val[0] && val[0].singleReport;
- let allSame = true;
- val.forEach((item) => {
- if (item.singleReport !== initReportValue) {
- allSame = false;
- }
- });
- if (!allSame) {
- return this.$message.warning('请选择报工类型相同的工单');
- }
- let ids = [];
- ids = val.map((item) => {
- return item.id;
- });
- this.$emit('workSelect', { ids: ids, list: val });
- },
- rowClick(e) {
- this.$emit('rowClick', e, this.taskObj.id);
- },
- cellClick() {
- this.$nextTick(() => {
- this.$emit('getTaskName', this.selection);
- });
- },
- handRoute(row) {
- this.routeObj = row;
- this.routingShow = true;
- },
- closeRoute() {
- this.routingShow = false;
- },
- handleResize() {
- this.internalIsFullscreen = isFullscreen();
- }
- }
- };
- </script>
- <style lang="scss" scoped></style>
|