Explorar o código

字典修改、执行方式页面完成

lucw hai 7 meses
pai
achega
0a53c303c3

+ 49 - 0
src/api/recordrulesexecutemethod/index.js

@@ -0,0 +1,49 @@
+import request from '@/utils/request';
+// 记录规则执行方式
+
+// /main/recordrulesexecutemethod/page
+export async function recordrulesexecutemethodPage(body) {
+  const res = await request.post(`/main/recordrulesexecutemethod/page`, body);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// /main/recordrulesexecutemethod/getById/{id}
+export async function recordrulesexecutemethodGetById(id) {
+  const res = await request.get(`/main/recordrulesexecutemethod/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// /main/recordrulesexecutemethod/delete
+export async function recordrulesexecutemethodDelete(data) {
+  const res = await request.delete(`/main/recordrulesexecutemethod/delete`, {
+    data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// /main/recordrulesexecutemethod/save
+export async function recordrulesexecutemethodSave(body) {
+  const res = await request.post(`/main/recordrulesexecutemethod/save`, body);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// /main/recordrulesexecutemethod/update
+export async function recordrulesexecutemethodUpdate(body) {
+  const res = await request.put(`/main/recordrulesexecutemethod/update`, body);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 1 - 1
src/enum/dict.js

@@ -76,7 +76,7 @@ export default {
   物品颜色: 'product_color_key',
   记录规则类型: 'record_sheet',
   记录规则报工类型: 'record_rules_report_work_type',
-  记录规则执行方式: 'record_rules_execute_method',
+  记录规则执行方式: 'produce_task_config_execute_method',
   记录规则事项类型: 'record_rules_item_type',
   班次出勤名称: 'attendance_name',
   班次时间类型: 'workShift_tiemType'

+ 160 - 0
src/views/rulesManagement/recordrulesexecutemethod/components/ProduceDialog.vue

@@ -0,0 +1,160 @@
+<template>
+  <ele-modal
+    width="70vw"
+    :visible.sync="visible"
+    :close-on-click-modal="false"
+    append-to-body
+    custom-class="ele-dialog-form"
+    title="选择工序"
+    :maxable="true"
+  >
+    <seek-page :seekList="seekList" @search="search"></seek-page>
+
+    <ele-pro-table
+      :columns="columns"
+      :datasource="datasource"
+      @cell-click="cellClick"
+      ref="table"
+      height="45vh"
+      :initLoad="false"
+      row-key="id"
+    >
+      <!-- 表头工具栏 -->
+      <template v-slot:action="{ row }">
+        <el-radio class="radio" v-model="radio" :label="row.id"
+          ><i></i
+        ></el-radio>
+      </template>
+    </ele-pro-table>
+
+    <div slot="footer">
+      <el-button type="primary" @click="confirm">确定</el-button>
+      <el-button @click="cancel">返回</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import { getProduceList } from '@/api/factoryModel';
+  import producetask from '@/api/technology/production';
+  export default {
+    data() {
+      return {
+        visible: false,
+        isUpdate: false,
+        selection: [],
+        searchData: {
+          code: '',
+          name: ''
+        },
+        columns: [
+          {
+            prop: 'code',
+            label: '工序编码',
+            // sortable: 'custom',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'name',
+            label: '工序名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            align: 'center',
+            prop: 'controlName',
+            label: '工序控制码',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'workCenterName',
+            label: '所属工作中心',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+
+          {
+            action: 'action',
+            slot: 'action',
+            align: 'center',
+            label: '选择'
+          }
+        ],
+        radio: null
+      };
+    },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '工序名称:',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '工序编码:',
+            value: 'code',
+            type: 'input',
+            placeholder: '请输入'
+          }
+        ];
+      }
+    },
+    methods: {
+      open(item) {
+        if (item) {
+          this.current = {
+            id: item.taskIds,
+            name: item.taskNames
+          };
+        }
+        this.radio = item.taskIds;
+        this.visible = true;
+        this.$nextTick(() => {
+          this.$refs.table.reload();
+        });
+      },
+      /* 表格数据源 */
+      async datasource({ page, limit, where, order }) {
+        const res = await producetask.list({
+          ...where,
+          pageNum: page,
+          size: limit
+        });
+        return res;
+      },
+      cancel() {
+        this.current = null;
+        this.radio = '';
+        this.searchData = {};
+        this.visible = false;
+      },
+      confirm() {
+        if (!this.current.id || !this.current.name) {
+          return this.$message.warning('请选择工序');
+        }
+        this.$emit('changeProduct', this.current);
+        this.cancel();
+      },
+
+      // 单击获取id
+      cellClick(row) {
+        this.current = row;
+        this.radio = row.id;
+      },
+      search(where) {
+        this.$refs.table.reload({ where });
+      },
+      reset() {
+        this.searchData = {};
+        this.$refs.table.reload();
+      }
+    }
+  };
+</script>

+ 203 - 0
src/views/rulesManagement/recordrulesexecutemethod/components/edit.vue

@@ -0,0 +1,203 @@
+<template>
+  <ele-modal
+    :title="title"
+    :visible.sync="visible"
+    :close-on-click-modal="false"
+    @close="handleClose"
+    resizable
+    maxable
+    width="800px"
+  >
+    <div v-loading="loading">
+      <el-form
+        ref="formRef"
+        :model="form"
+        :rules="rules"
+        label-width="120px"
+        :disabled="type == 'view'"
+      >
+        <el-row style="margin-bottom: 20px" :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="执行方式编码" prop="code">
+              <el-input
+                v-model="form.code"
+                placeholder="系统自动生成"
+                disabled
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="执行方式名称" prop="name">
+              <el-input
+                v-model="form.name"
+                placeholder="请输入执行方式名称"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row style="margin-bottom: 20px" :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="所属工序" prop="produceTaskName">
+              <el-input
+                v-model="form.produceTaskName"
+                placeholder="请选择工序"
+                readonly
+                @click.native="openProduceTaskDialog"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="状态" prop="enable">
+              <el-switch
+                v-model="form.enable"
+                :active-value="1"
+                :inactive-value="0"
+                active-text="生效"
+                inactive-text="失效"
+              ></el-switch>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+
+      <ProduceDialog
+        ref="produceDialogRef"
+        @changeProduct="selectProduceTask"
+      />
+    </div>
+
+    <template v-slot:footer>
+      <el-button
+        v-if="type != 'view'"
+        type="primary"
+        @click="submit"
+        :loading="butLoading"
+        >保 存</el-button
+      >
+      <el-button @click="handleClose" :loading="butLoading">关 闭</el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import ProduceDialog from './ProduceDialog.vue';
+  import {
+    recordrulesexecutemethodSave,
+    recordrulesexecutemethodUpdate,
+    recordrulesexecutemethodGetById
+  } from '@/api/recordrulesexecutemethod/index';
+  import { load } from '@amap/amap-jsapi-loader';
+
+  export default {
+    mixins: [dictMixins],
+    components: { ProduceDialog },
+    data() {
+      const formBaseData = {
+        id: null,
+        code: '',
+        name: '',
+        createUserName: '',
+        enable: 1,
+        produceTaskId: null,
+        produceTaskName: '',
+        updateUserName: ''
+      };
+
+      return {
+        visible: false,
+        title: '执行方式',
+        formBaseData,
+        form: JSON.parse(JSON.stringify(formBaseData)),
+        rules: {
+          name: [
+            { required: true, message: '请输入执行方式名称', trigger: 'blur' },
+            { required: true, message: '请输入执行方式名称', trigger: 'change' }
+          ],
+          produceTaskName: [
+            { required: true, message: '请选择所属工序', trigger: 'blur' },
+            { required: true, message: '请选择所属工序', trigger: 'change' }
+          ],
+          enable: [
+            { required: true, message: '请选择状态', trigger: 'blur' },
+            { required: true, message: '请选择状态', trigger: 'change' }
+          ]
+        },
+        // 工序列表
+        produceTaskList: [],
+        butLoading: false,
+        type: 'add', // add/edit/view
+        loading: false
+      };
+    },
+    methods: {
+      // 外部调用,打开弹窗
+      open(type, data = {}) {
+        console.log('data', data);
+        this.type = type;
+        if (type === 'add') {
+          this.title = '新增执行方式';
+          this.form.updateUserName = '';
+          this.form.createUserName = this.$store.state.user.info.name;
+        } else if (type === 'edit') {
+          this.title = '修改执行方式';
+          this.form.updateUserName = this.$store.state.user.info.name;
+          this.getDetails(data.id);
+        } else if (type === 'view') {
+          this.title = '执行方式详情';
+          this.getDetails(data.id);
+        }
+        console.log('this.form', this.form);
+        this.visible = true;
+      },
+      async getDetails(id) {
+        this.loading = true;
+        const data = await recordrulesexecutemethodGetById(id);
+        this.$util.assignObject(this.form, data);
+        this.loading = false;
+      },
+      // 关闭时清理表单
+      handleClose() {
+        this.form = JSON.parse(JSON.stringify(this.formBaseData));
+        this.$nextTick(() => {
+          this.$refs.formRef.clearValidate();
+          this.visible = false;
+        });
+      },
+      // 提交
+      submit() {
+        console.log('this.form', this.form);
+        this.$refs.formRef.validate(async (valid) => {
+          console.log('valid', valid, this.type);
+          if (valid) {
+            this.butLoading = true;
+            if (this.type === 'add') {
+              await recordrulesexecutemethodSave(this.form);
+              this.$message.success('新增成功');
+            } else if (this.type === 'edit') {
+              await recordrulesexecutemethodUpdate(this.form);
+              this.$message.success('修改成功');
+            }
+            this.butLoading = false;
+            this.$emit('refreshTable');
+            this.handleClose();
+          }
+        });
+      },
+      // 选择工序
+      openProduceTaskDialog() {
+        this.$refs.produceDialogRef.open({
+          id: this.form.produceTaskId,
+          name: this.form.produceTaskName
+        });
+      },
+      selectProduceTask(produceTask) {
+        console.log('produceTask', produceTask);
+        this.form.produceTaskId = produceTask.id;
+        this.form.produceTaskName = produceTask.name;
+      }
+    }
+  };
+</script>
+
+<style scoped lang="scss"></style>

+ 199 - 0
src/views/rulesManagement/recordrulesexecutemethod/index.vue

@@ -0,0 +1,199 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <seek-page :seekList="seekList" @search="search"></seek-page>
+      <ele-pro-table
+        ref="table"
+        row-key="id"
+        :columns="columns"
+        :datasource="datasource"
+        :cache-key="cacheKeyUrl"
+        autoAmendPage
+      >
+        <template v-slot:toolbar>
+          <el-button type="primary" @click="openEdit('add')">新增</el-button>
+        </template>
+        <template v-slot:code="{ row }">
+          <el-button type="text" @click="openEdit('view', row)">{{
+            row.code
+          }}</el-button>
+        </template>
+        <template v-slot:action="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-edit"
+            @click="openEdit('edit', row)"
+          >
+            编辑
+          </el-link>
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除此条数据吗?"
+            @confirm="deleteRow(row)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
+        </template>
+      </ele-pro-table>
+    </el-card>
+
+    <edit ref="editRef" @refreshTable="reload"></edit>
+  </div>
+</template>
+
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import tableColumnsMixin from '@/mixins/tableColumnsMixin';
+  import edit from './components/edit.vue';
+  import {
+    recordrulesexecutemethodPage,
+    recordrulesexecutemethodDelete
+  } from '@/api/recordrulesexecutemethod/index';
+
+  export default {
+    mixins: [dictMixins, tableColumnsMixin],
+    components: { edit },
+    data() {
+      return {
+        columns: [
+          {
+            width: 50,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center',
+            label: '序号'
+          },
+          {
+            prop: 'code',
+            label: '执行方式编码',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true,
+            slot: 'code'
+          },
+          {
+            prop: 'name',
+            label: '执行方式名称',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'produceTaskName',
+            label: '所属工序',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'enable',
+            label: '状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (row) => {
+              return row.enable ? '生效' : '失效';
+            }
+          },
+          {
+            prop: 'createUserName',
+            label: '创建人',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 220,
+            align: 'center',
+            resizable: false,
+            fixed: 'right',
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ],
+        cacheKeyUrl: 'mes-2510301052-recordrulesexecutemethod-table'
+      };
+    },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '执行方式名称:',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '所属工序:',
+            value: 'produceTaskId',
+            type: 'select',
+            placeholder: '请选择',
+            planList: []
+          },
+          {
+            label: '状态:',
+            value: 'enable',
+            type: 'select',
+            placeholder: '请选择',
+            planList: [
+              {
+                label: '生效',
+                value: 1
+              },
+              {
+                label: '失效',
+                value: 0
+              }
+            ]
+          }
+        ];
+      }
+    },
+    methods: {
+      // 刷新表格
+      reload(where = {}) {
+        this.$refs.table.reload({
+          where
+        });
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        // 参数
+        const body = {
+          ...where,
+          ...order,
+          pageNum: page,
+          size: limit
+        };
+        return recordrulesexecutemethodPage(body);
+      },
+      search(where) {
+        this.reload(where);
+      },
+      openEdit(type, data = {}) {
+        this.$refs.editRef.open(type, data);
+      },
+      async deleteRow(row) {
+        await recordrulesexecutemethodDelete([row.id]);
+        this.$message.success('删除成功');
+        this.reload();
+      }
+    }
+  };
+</script>
+
+<style></style>

+ 1 - 1
src/views/rulesManagement/releaseRules/index.vue

@@ -164,7 +164,7 @@
             minWidth: 110
           },
           {
-            prop: 'name',
+            prop: 'executeMethodName',
             label: '执行方式',
             align: 'center',
             showOverflowTooltip: true,

+ 1 - 1
src/views/technology/production/components/user-setting-matter-add.vue

@@ -182,7 +182,7 @@
         deviceId: null,
         //设备名称
         deviceName: '',
-        // 记录规则执行方式,参考字典项:record_rules_execute_method
+        // 记录规则执行方式,参考字典项:produce_task_config_execute_method
         executeMethod: '2',
         // 记录规则事项类型,参考字典项:record_rules_item_type
         itemType: '2',