| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <template>
- <ele-modal
- :visible.sync="visible"
- title="添加工单-选择设备"
- width="65vw"
- append-to-body
- >
- <div class="search-box">
- 工位编码:
- <el-input placeholder="请输入" v-model="searchKey"></el-input>
- </div>
- <!-- 数据表格 -->
- <!-- :highlight-current-row="isSingle" -->
- <ele-pro-table
- ref="table"
- :columns="columns"
- @done="handleDone"
- row-key="id"
- :selection.sync="selectionList"
- :datasource="datasource"
- :current.sync="current"
- highlight-current-row
- height="45vh"
- @row-click="choose"
- >
- <template v-slot:select="{ row }">
- <el-radio class="radio" v-model="radio" :label="row.id"
- ><i></i
- ></el-radio>
- </template>
- </ele-pro-table>
- <div class="footer" slot="footer">
- <el-button @click="cancel">取消</el-button>
- <el-button @click="confirm" type="primary">确定</el-button>
- </div>
- </ele-modal>
- </template>
- <script>
- import { factoryworkstation } from '@/api/mainData/index';
- export default {
- props: {
- produceVersionId: {
- type: String,
- default: ''
- },
- isPlan: {
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- visible: false,
- current: null,
- searchKey: '',
- selectionList: [],
- memoList: [],
- isSingle: false,
- callback: null,
- radio: ''
- };
- },
- computed: {
- columns () {
- const list = [
- {
- prop: 'code',
- label: '工位编码'
- },
- {
- label: '工位名称',
- prop: 'name'
- },
- {
- label: '责任人',
- prop: 'leaderName',
- slot: 'factory'
- },
- {
- label: '所属车间',
- prop: 'workshopName'
- },
- {
- label: '所属产线',
- prop: 'productionLineName'
- }
- ];
- if (!this.isSingle) {
- list.push({
- slot: 'select',
- prop: 'select',
- label: '选择',
- align: 'center'
- });
- }
- return list;
- }
- },
- methods: {
- open (list = []) {
- this.memoList = list;
- this.isSingle = false;
- this.visible = true;
- },
- openSingle (list = [], callback) {
- this.memoList = list;
- this.callback = callback;
- this.isSingle = true;
- this.visible = true;
- },
- handleDone ({ data }) {
- if (this.memoList.length) {
- this.$nextTick(() => {
- if (this.isSingle) {
- this.$refs.table.setCurrentRow(
- data.find(
- (item) =>
- item.id ==
- (this.memoList[0].deviceId ||
- this.memoList[0].sourceInstanceId)
- )
- );
- } else {
- this.memoList.length &&
- this.$refs.table.setSelectedRowKeys(
- this.memoList.map((i) => i.deviceId)
- );
- }
- });
- }
- },
- datasource ({ page, limit }) {
- return factoryworkstation({
- pageNum: page,
- size: limit,
- code: this.searchKey
- });
- },
- confirm () {
- if (this.isSingle) {
- if (!this.current) return this.$message.error('请选择数据');
- this.callback && this.callback(this.current);
- } else {
- if (!this.current) return this.$message.error('请选择数据');
- this.$emit('success', [this.current]);
- }
- this.cancel();
- },
- cancel () {
- this.$refs.table.setCurrentRow();
- this.$refs.table.clearSelection();
- this.radio = '';
- this.current = null;
- this.visible = false;
- },
- // 单击获取id
- choose (row) {
- this.current = row;
- this.radio = row.id;
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .search-box {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- margin-bottom: 20px;
- .el-input {
- width: 220px;
- margin: 0 32px;
- }
- }
- </style>
|