| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <ele-modal
- :visible="visible"
- :append-to-body="true"
- :close-on-click-modal="false"
- custom-class="ele-dialog-form"
- title="选择计划规则"
- @update:visible="updateVisible"
- :maxable="true"
- width="90%"
- :before-close="handleClose"
- >
- <el-card shadow="never" v-loading="loading">
- <seekPage :seekList="seekList" @search="reload" :maxLength="4"></seekPage>
- <ele-pro-table
- ref="tableRef"
- :columns="columns"
- :datasource="datasource"
- :selection.sync="selection"
- cache-key="select-plan-rules-table-2511141448"
- >
- <!-- 单选列 -->
- <template v-slot:radio="{ row }">
- <el-radio
- class="radio"
- v-model="currentRowId"
- :label="row.id"
- @change="radioChange($event, row)"
- ><i></i
- ></el-radio>
- </template>
- </ele-pro-table>
- </el-card>
- <template v-slot:footer>
- <el-button type="primary" @click="confirmSelection"> 选择 </el-button>
- <el-button @click="visible = false">关闭</el-button>
- </template>
- </ele-modal>
- </template>
- <script>
- import tabMixins from '@/mixins/tableColumnsMixin';
- import dictMixins from '@/mixins/dictMixins';
- import { planConfigPage } from '@/api/ruleManagement/plan.js';
- export default {
- components: {},
- mixins: [tabMixins, dictMixins],
- props: {
- // 是否多选
- multiple: {
- type: Boolean,
- default: false
- },
- // 默认 筛选条件
- where: {
- type: Object,
- default: () => ({
- // 生效
- status: 1
- })
- },
- // 1巡点检 2保养
- ruleTypes: {
- type: Array,
- default: () => {
- return [1, 2];
- }
- }
- },
- computed: {
- columns() {
- const list = [
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'code',
- label: '计划配置单号',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- slot: 'code'
- },
- {
- prop: 'name',
- label: '计划配置名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- ...[
- this.ruleType == 1
- ? {
- prop: 'groupName',
- label: '巡点检部门',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- slot: 'groupName'
- }
- : {
- prop: 'groupName',
- label: '部门',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- slot: 'groupName'
- }
- ],
- {
- prop: 'categoryName',
- label: '设备分类',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'ruleName',
- label: '规则名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'autoOrder',
- label: '自动派单',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row) => {
- let autoOrder =
- _row.autoOrder == 1 ? '是' : _row.autoOrder == 0 ? '否' : '-';
- return autoOrder;
- }
- },
- {
- //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
- prop: 'status',
- label: '状态',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row) => {
- return this.getDictValue('规则状态', _row.status);
- },
- filters: [
- { value: 1, text: '生效' },
- { value: 0, text: '失效' }
- ],
- filterMultiple: false,
- columnKey: 'status'
- },
- {
- prop: 'createUserName',
- label: '创建人',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row, _column, cellValue) => {
- return this.$util.toDateString(cellValue);
- }
- }
- ];
- if (this.multiple) {
- list.unshift({
- type: 'selection',
- width: 50,
- align: 'center',
- fixed: 'left'
- });
- } else {
- list.unshift({
- prop: 'radio',
- width: 50,
- align: 'center',
- fixed: 'left',
- slot: 'radio'
- });
- }
- return list;
- },
- seekList() {
- return [
- {
- label: '规则名称:',
- value: 'name',
- type: 'input',
- placeholder: '规则名称'
- },
- {
- label: '规则编码:',
- value: 'code',
- type: 'input',
- placeholder: '规则编码'
- }
- ];
- }
- },
- data() {
- return {
- loading: false,
- visible: false,
- selection: [],
- produceTaskId: '',
- reportWorkType: '', // 事项报工类型 产前、过程、产后
- currentRowId: null,
- currentRow: null
- };
- },
- created() {
- this.requestDict('事项类型');
- this.requestDict('规则周期');
- },
- methods: {
- open() {
- this.visible = true;
- this.reload(); // 刷新表格
- },
- updateVisible(val) {
- this.visible = val;
- },
- /* 表格数据源 */
- datasource({ page, limit, where }) {
- return planConfigPage({
- pageNum: page,
- size: limit,
- ...where,
- ...this.where,
- ruleTypes: this.ruleTypes
- });
- },
- /* 刷新表格 */
- reload(where = {}) {
- this.$refs.tableRef?.reload({
- page: 1, // 已发布
- where
- });
- },
- confirmSelection() {
- if (this.multiple && this.selection.length === 0) {
- this.$message.warning('请先选择事项');
- return;
- }
- if (!this.multiple && !this.currentRow) {
- this.$message.warning('请先选择事项');
- return;
- }
- this.$emit(
- 'chooseRules',
- this.multiple ? this.selection : this.currentRow
- );
- this.handleClose();
- },
- radioChange(_, row) {
- this.currentRow = row;
- },
- handleClose() {
- this.selection = [];
- this.currentRowId = null;
- this.currentRow = null;
- this.visible = false;
- }
- }
- };
- </script>
|