Răsfoiți Sursa

车间、产线

jabin 3 ani în urmă
părinte
comite
e0ea0c9aad

+ 23 - 0
src/api/factoryModel/factoryManagement/index.js → src/api/factoryModel/index.js

@@ -1,4 +1,25 @@
 import request from '@/utils/request';
+// 获取车间下的所有产线
+export async function listFactoryLineByParentId(params) {
+    const res = await request.get(
+        `/main/factoryarea/listFactoryLineByParentId/${params}`, {}
+    );
+    if (res.data.code == 0) {
+        return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+}
+// 获取工厂下的所有车间
+export async function listWorkshopByParentId(params) {
+    const res = await request.get(
+        `/main/factoryarea/listWorkshopByParentId/${params}`, {}
+    );
+    if (res.data.code == 0) {
+        return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+}
+// 保存
 export async function saveOrUpdate(params) {
     const res = await request.post(
         `/main/factoryarea/saveOrUpdate`,
@@ -9,6 +30,7 @@ export async function saveOrUpdate(params) {
     }
     return Promise.reject(new Error(res.data.message));
 }
+// 查询工厂列表-分页
 export async function getFactoryarea(params) {
     const res = await request.get(
         `/main/factoryarea/page`,
@@ -21,6 +43,7 @@ export async function getFactoryarea(params) {
     }
     return Promise.reject(new Error(res.data.message));
 }
+// 删除
 export async function deletefactoryarea(params) {
     const res = await request.get(
         `/main/factoryarea/delete/${params}`,

+ 1 - 1
src/views/factoryModel/factoryManagement/components/edit.vue

@@ -109,7 +109,7 @@
 <script>
 import { cityDataLabel } from 'ele-admin/packages/utils/regions';
 import { listOrganizations } from '@/api/system/organization';
-import { saveOrUpdate } from '@/api/factoryModel/factoryManagement';
+import { saveOrUpdate } from '@/api/factoryModel';
 export default {
   data() {
     const defaultForm = {

+ 1 - 4
src/views/factoryModel/factoryManagement/index.vue

@@ -56,10 +56,7 @@
 <script>
 import search from './components/search.vue';
 import edit from './components/edit.vue';
-import {
-  getFactoryarea,
-  deletefactoryarea
-} from '@/api/factoryModel/factoryManagement';
+import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
 import { listOrganizations } from '@/api/system/organization';
 export default {
   components: {

+ 473 - 0
src/views/factoryModel/plant/components/edit.vue

@@ -0,0 +1,473 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <el-dialog
+    class="ele-dialog-form"
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    width="1200px"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
+      <el-row>
+        <el-col :span="8">
+          <el-form-item
+            label="厂房编码:"
+            prop="code"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.code"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item
+            label="厂房名称:"
+            prop="name"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.name"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="状态:" prop="enabled">
+            <el-select
+              v-model="form.enabled"
+              placeholder="请选择"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options.enabled"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="所属工厂:" prop="parentId">
+            <el-select
+              v-model="form.parentId"
+              placeholder="请选择"
+              @change="change_factoryId"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options_factory"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item
+            label="负责人部门:"
+            prop="extInfo.principalDep"
+            style="margin-bottom: 22px"
+          >
+            <ele-tree-select
+              clearable
+              :data="options.principalDep"
+              v-model="form.extInfo.principalDep"
+              valueKey="id"
+              labelKey="name"
+              placeholder="请选择"
+              @change="change_principalDep"
+              default-expand-all
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="负责人:" prop="extInfo.principal">
+            <el-select
+              v-model="form.extInfo.principal"
+              placeholder="请选择"
+              @change="change_principal"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options.principal"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="联系方式:" prop="extInfo.phone">
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.extInfo.phone"
+              οninput="value=value.replace(/[^\d]/g,'');if(value.length > 11)value = value.slice(0, 11)"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item prop="extInfo.assetCode" label="房屋资产编码">
+            <el-input
+              class="form-ipt"
+              size="small"
+              style="width: 100%"
+              placeholder="请输入"
+              v-model="form.extInfo.assetCode"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item prop="extInfo.campus" label="归属园院区">
+            <el-input
+              class="form-ipt"
+              size="small"
+              style="width: 100%"
+              placeholder="请输入"
+              v-model="form.extInfo.campus"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item prop="extInfo.coveredArea" label="建筑面积">
+            <el-input
+              class="form-ipt"
+              size="small"
+              style="width: 100%"
+              placeholder="请输入"
+              v-model="form.extInfo.coveredArea"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item prop="extInfo.level" label="楼层">
+            <el-input
+              class="form-ipt"
+              size="small"
+              style="width: 100%"
+              placeholder="请输入"
+              v-model="form.extInfo.level"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item prop="extInfo.moneyCeiling" label="已配金额上限">
+            <el-input
+              class="form-ipt"
+              size="small"
+              style="width: 100%"
+              placeholder="请输入"
+              v-model="form.extInfo.moneyCeiling"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item prop="extInfo.useArea" label="使用面积">
+            <el-input
+              class="form-ipt"
+              size="small"
+              style="width: 100%"
+              placeholder="请输入"
+              v-model="form.extInfo.useArea"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" style="margin-bottom: 22px">
+          <el-form-item label="地址:" prop="extInfo.location">
+            <div class="location-warp">
+              <el-cascader
+                clearable
+                style="width: 400px"
+                v-model="form.extInfo.location"
+                :options="options.cityDataLabel"
+              ></el-cascader>
+              <el-input
+                class="detail"
+                clearable
+                :maxlength="20"
+                v-model="form.extInfo.locationDetail"
+                placeholder="请输入详细地址"
+              />
+            </div>
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" style="margin-bottom: 22px">
+          <el-form-item label="备注:" prop="remark">
+            <el-input
+              clearable
+              :maxlength="100"
+              type="textarea"
+              v-model="form.remark"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button type="primary" :loading="loading" @click="save">
+        保存
+      </el-button>
+    </template>
+  </el-dialog>
+</template>
+
+<script>
+import { saveOrUpdate, listWorkshopByParentId } from '@/api/factoryModel';
+import { getUserPage } from '@/api/system/organization';
+import { cityDataLabel } from 'ele-admin/packages/utils/regions';
+export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
+  data() {
+    const defaultForm = {
+      id: '',
+      code: '',
+      name: '',
+      extInfo: {
+        principal: '', // 负责人
+        principalDep: '', // 负责人部门
+        phone: '', // 手机号
+        locationDetail: '', // 详细地址
+        location: [], // 省市区
+        assetCode: '', //房屋资产编码
+        campus: '', //归属园院区
+        coveredArea: '', //建筑面积
+        level: '', //楼层
+        moneyCeiling: '', //已配金额上限
+        useArea: '' // 使用面积
+      },
+      groupId: '',
+      enabled: 1,
+      parentId: '',
+      remark: '',
+      type: 4 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm },
+      // 表单验证规则
+      rules: {
+        code: [{ required: true, message: '请输入', trigger: 'blur' }],
+        name: [{ required: true, message: '请输入', trigger: 'blur' }],
+        'extInfo.factoryId': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        parentId: { required: true, message: '请输入', trigger: 'change' },
+        enabled: { required: true, message: '请输入', trigger: 'change' },
+        'extInfo.principalDep': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        'extInfo.principal': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        'extInfo.phone': [
+          { min: 11, message: '手机号格式不正确', trigger: 'blur' }
+        ],
+        'extInfo.assetCode': [
+          { required: true, message: '请输入', trigger: 'blur' }
+        ],
+
+        'extInfo.campus': [
+          { required: true, message: '请输入', trigger: 'blur' }
+        ],
+        'extInfo.coveredArea': [
+          { required: true, message: '请输入', trigger: 'blur' }
+        ],
+        'extInfo.level': [
+          { required: true, message: '请输入', trigger: 'blur' }
+        ],
+
+        'extInfo.moneyCeiling': [
+          { required: true, message: '请输入', trigger: 'blur' }
+        ],
+        'extInfo.useArea': [
+          { required: true, message: '请输入', trigger: 'blur' }
+        ]
+      },
+      visible: false,
+      type: '', // add/edit
+      loading: false,
+      options: {
+        principalDep: [],
+        principal: [],
+        workshop: [],
+        enabled: [
+          {
+            label: '生效',
+            value: 1
+          },
+          {
+            label: '未生效',
+            value: 0
+          }
+        ],
+        cityDataLabel
+      }
+    };
+  },
+  computed: {
+    title() {
+      switch (this.type) {
+        case 'add':
+          return '新增厂房';
+          break;
+        case 'edit':
+          return '编辑厂房';
+          break;
+        default:
+          break;
+      }
+    }
+  },
+  methods: {
+    open(type, row) {
+      this.type = type;
+      this.visible = true;
+      if (type == 'edit') {
+        for (const key of Object.keys(this.form)) {
+          if (key !== 'extInfo') {
+            this.form[key] = row[key];
+          } else {
+            for (const el of Object.keys(this.form.extInfo)) {
+              this.form.extInfo[el] = row.extInfo[el];
+            }
+          }
+        }
+        // 请求下拉数据
+        if (this.form.extInfo.factoryId) {
+          this.getListWorkshopByParentId();
+        }
+        if (this.form.extInfo.principalDep) {
+          this.getUserPage();
+        }
+      }
+    },
+    /* 保存编辑 */
+    save() {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+        this.loading = true;
+
+        if (this.type == 'add') {
+          delete this.form.id;
+        }
+        saveOrUpdate(this.form)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.handleClose();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+            this.$message.error(e.message);
+          });
+      });
+    },
+    restForm() {
+      this.$refs.form.clearValidate();
+      this.form = { ...this.defaultForm };
+    },
+    handleClose() {
+      this.restForm();
+      this.visible = false;
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.principalDep = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    },
+    // 获取车间
+    getListWorkshopByParentId() {
+      listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
+        this.options.workshop = res;
+      });
+    },
+    // 获取人员
+    getUserPage() {
+      let par = {
+        groupId: this.form.extInfo.principalDep,
+        size: 999
+      };
+      getUserPage(par).then((res) => {
+        this.options.principal = res.list;
+      });
+    },
+    // 选择工厂
+    change_factoryId() {
+      this.form.parentId = '';
+      this.form.groupId = '';
+      this.options.workshop = [];
+      this.getListWorkshopByParentId();
+    },
+    // 选择负责人部门
+    change_principalDep() {
+      this.form.extInfo.principal = '';
+      this.options.principal = [];
+      this.getUserPage();
+    },
+    // 选择车间
+    change_workshop() {
+      let result = this.options.workshop.find(
+        (n) => n.id == this.form.parentId
+      );
+      this.form.groupId = result.groupId;
+    },
+    // 选择负责人
+    change_principal() {
+      let result = this.options.principal.find(
+        (n) => n.id == this.form.extInfo.principal
+      );
+      this.form.extInfo.phone = result.phone;
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.location-warp {
+  display: flex;
+  .detail {
+    margin-left: 10px;
+  }
+}
+</style>

+ 100 - 0
src/views/factoryModel/plant/components/search.vue

@@ -0,0 +1,100 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="15">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="产线编码:">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="产线名称:">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+          <el-button @click="reset">重置</el-button>
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
+  data() {
+    // 默认表单数据
+    const defaultWhere = {
+      code: '',
+      name: ''
+    };
+    return {
+      defaultWhere,
+      // 表单数据
+      where: { ...defaultWhere },
+      options: {
+        groupId: []
+      }
+    };
+  },
+  computed: {
+    // 是否开启响应式布局
+    styleResponsive() {
+      return this.$store.state.theme.styleResponsive;
+    }
+  },
+  methods: {
+    /* 搜索 */
+    search() {
+      this.$emit('search', this.where);
+    },
+    /*  重置 */
+    reset() {
+      console.log(this.defaultWhere);
+      this.where = { ...this.defaultWhere };
+      this.search();
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.groupId = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    }
+  }
+};
+</script>

+ 211 - 0
src/views/factoryModel/plant/index.vue

@@ -0,0 +1,211 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <search
+        ref="search"
+        @search="search"
+        :options_groupId="dict.groupId"
+        :options_factory="dict.factory"
+      ></search>
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        cache-key="systemRoleTable"
+      >
+        <!-- 表头工具栏 -->
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit('add')"
+          >
+            添加
+          </el-button>
+        </template>
+        <template v-slot:workshop="{ row }">
+          {{ showWorkshop(row) }}
+        </template>
+        <template v-slot:factory="{ row }">
+          {{ showgfactory(row) }}
+        </template>
+        <template v-slot:enabled="{ row }">
+          {{ dict.enabled[row.enabled] }}
+        </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="remove(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="edit"
+      @done="done"
+      :options_groupId="dict.groupId"
+      :options_factory="dict.factory"
+    ></edit>
+  </div>
+</template>
+<script>
+import search from './components/search.vue';
+import edit from './components/edit.vue';
+import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
+import { listOrganizations } from '@/api/system/organization';
+export default {
+  components: {
+    search,
+    edit
+  },
+  data() {
+    return {
+      columns: [
+        {
+          width: 45,
+          type: 'index',
+          columnKey: 'index',
+          align: 'center'
+        },
+        {
+          prop: 'code',
+          label: '产线编码'
+        },
+        {
+          label: '产线名称',
+          prop: 'name'
+        },
+        {
+          label: '所属工厂',
+          prop: 'extInfo.factoryId',
+          slot: 'factory'
+        },
+        {
+          label: '所属车间',
+          prop: 'parentId',
+          slot: 'workshop'
+        },
+        {
+          label: '省/市/区',
+          prop: 'extInfo.location'
+        },
+        {
+          label: '详细地址',
+          prop: 'extInfo.locationDetail'
+        },
+        {
+          label: '状态',
+          prop: 'enabled',
+          slot: 'enabled'
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 220,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      dict: {
+        groupId: [],
+        factory: [],
+        enabled: {
+          1: '生效',
+          0: '未生效'
+        }
+      }
+    };
+  },
+  created() {
+    this.getGs();
+    this.getFactoryarea();
+  },
+  methods: {
+    datasource({ page, where, limit }) {
+      return getFactoryarea({
+        ...where,
+        pageNum: page,
+        size: limit,
+        type: 4
+      });
+    },
+    search(where) {
+      this.$refs.table.reload({
+        where: where,
+        page: 1
+      });
+    },
+    openEdit(type, row) {
+      this.$refs.edit.open(type, row);
+    },
+    // 获取公司数据
+    getGs() {
+      listOrganizations().then((list) => {
+        console.log(list);
+        this.dict.groupId = list;
+      });
+    },
+    // 回显工厂名称
+    showgfactory(row) {
+      let result = row.parent.find((n) => n.id == row.extInfo.factoryId);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    // 回显车间
+    showWorkshop(row) {
+      let result = row.parent.find((n) => n.id == row.parentId);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    // 获取工厂数据
+    getFactoryarea() {
+      let par = {
+        type: 1,
+        size: 9999
+      };
+      getFactoryarea(par).then((res) => {
+        this.dict.factory = res.list;
+      });
+    },
+    remove(row) {
+      deletefactoryarea(row.id)
+        .then((message) => {
+          this.$message.success(message);
+          this.done();
+        })
+        .catch((e) => {
+          this.$message.error(e.message);
+        });
+    },
+    done() {
+      this.$refs.search.search();
+    }
+  }
+};
+</script>

+ 421 - 0
src/views/factoryModel/productionLine/components/edit.vue

@@ -0,0 +1,421 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <el-dialog
+    class="ele-dialog-form"
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    width="1200px"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-row>
+        <el-col :span="8">
+          <el-form-item
+            label="产线编码:"
+            prop="code"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.code"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item
+            label="产线名称:"
+            prop="name"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.name"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="所属工厂:" prop="extInfo.factoryId">
+            <el-select
+              v-model="form.extInfo.factoryId"
+              placeholder="请选择"
+              @change="change_factoryId"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options_factory"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="所属车间:" prop="parentId">
+            <el-select
+              v-model="form.parentId"
+              placeholder="请选择"
+              style="width: 100%"
+              @change="change_workshop"
+            >
+              <el-option
+                v-for="item in options.workshop"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item
+            label="负责人部门:"
+            prop="extInfo.principalDep"
+            style="margin-bottom: 22px"
+          >
+            <ele-tree-select
+              clearable
+              :data="options.principalDep"
+              v-model="form.extInfo.principalDep"
+              valueKey="id"
+              labelKey="name"
+              placeholder="请选择"
+              @change="change_principalDep"
+              default-expand-all
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="负责人:" prop="extInfo.principal">
+            <el-select
+              v-model="form.extInfo.principal"
+              placeholder="请选择"
+              @change="change_principal"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options.principal"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="联系方式:" prop="extInfo.phone">
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.extInfo.phone"
+              οninput="value=value.replace(/[^\d]/g,'');if(value.length > 11)value = value.slice(0, 11)"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="工作节拍:" prop="extInfo.workMeter">
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.extInfo.workMeter"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="加工能力:" prop="extInfo.workingAbility">
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.extInfo.workingAbility"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="状态:" prop="enabled">
+            <el-select
+              v-model="form.enabled"
+              placeholder="请选择"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options.enabled"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" style="margin-bottom: 22px">
+          <el-form-item label="地址:" prop="extInfo.location">
+            <div class="location-warp">
+              <el-cascader
+                clearable
+                style="width: 400px"
+                v-model="form.extInfo.location"
+                :options="options.cityDataLabel"
+              ></el-cascader>
+              <el-input
+                class="detail"
+                clearable
+                :maxlength="20"
+                v-model="form.extInfo.locationDetail"
+                placeholder="请输入详细地址"
+              />
+            </div>
+          </el-form-item>
+        </el-col>
+        <el-col :span="24" style="margin-bottom: 22px">
+          <el-form-item label="备注:" prop="remark">
+            <el-input
+              clearable
+              :maxlength="100"
+              type="textarea"
+              v-model="form.remark"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button type="primary" :loading="loading" @click="save">
+        保存
+      </el-button>
+    </template>
+  </el-dialog>
+</template>
+
+<script>
+import { saveOrUpdate, listWorkshopByParentId } from '@/api/factoryModel';
+import { getUserPage } from '@/api/system/organization';
+import { cityDataLabel } from 'ele-admin/packages/utils/regions';
+export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
+  data() {
+    const defaultForm = {
+      id: '',
+      code: '',
+      name: '',
+      extInfo: {
+        factoryId: '',
+        principal: '', // 负责人
+        principalDep: '', // 负责人部门
+        phone: '', // 手机号
+        workMeter: '', // 工作节拍
+        workingAbility: '', // 加工能力
+        locationDetail: '', // 详细地址
+        location: [] // 省市区
+      },
+      groupId: '',
+      enabled: 1,
+      parentId: '',
+      remark: '',
+      type: 4 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm },
+      // 表单验证规则
+      rules: {
+        code: [{ required: true, message: '请输入', trigger: 'blur' }],
+        name: [{ required: true, message: '请输入', trigger: 'blur' }],
+        'extInfo.factoryId': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        parentId: { required: true, message: '请输入', trigger: 'change' },
+        'extInfo.principalDep': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        'extInfo.principal': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        'extInfo.phone': [
+          { min: 11, message: '手机号格式不正确', trigger: 'blur' }
+        ]
+      },
+      visible: false,
+      type: '', // add/edit
+      loading: false,
+      options: {
+        principalDep: [],
+        principal: [],
+        workshop: [],
+        enabled: [
+          {
+            label: '生效',
+            value: 1
+          },
+          {
+            label: '未生效',
+            value: 0
+          }
+        ],
+        cityDataLabel
+      }
+    };
+  },
+  computed: {
+    title() {
+      switch (this.type) {
+        case 'add':
+          return '新增产线';
+          break;
+        case 'edit':
+          return '编辑产线';
+          break;
+        default:
+          break;
+      }
+    }
+  },
+  methods: {
+    open(type, row) {
+      this.type = type;
+      this.visible = true;
+      if (type == 'edit') {
+        for (const key of Object.keys(this.form)) {
+          if (key !== 'extInfo') {
+            this.form[key] = row[key];
+          } else {
+            for (const el of Object.keys(this.form.extInfo)) {
+              this.form.extInfo[el] = row.extInfo[el];
+            }
+          }
+        }
+        // 请求下拉数据
+        if (this.form.extInfo.factoryId) {
+          this.getListWorkshopByParentId();
+        }
+        if (this.form.extInfo.principalDep) {
+          this.getUserPage();
+        }
+      }
+    },
+    /* 保存编辑 */
+    save() {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+        this.loading = true;
+
+        if (this.type == 'add') {
+          delete this.form.id;
+        }
+        saveOrUpdate(this.form)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.handleClose();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+            this.$message.error(e.message);
+          });
+      });
+    },
+    restForm() {
+      this.$refs.form.clearValidate();
+      this.form = { ...this.defaultForm };
+    },
+    handleClose() {
+      this.restForm();
+      this.visible = false;
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.principalDep = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    },
+    // 获取车间
+    getListWorkshopByParentId() {
+      listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
+        this.options.workshop = res;
+      });
+    },
+    // 获取人员
+    getUserPage() {
+      let par = {
+        groupId: this.form.extInfo.principalDep,
+        size: 999
+      };
+      getUserPage(par).then((res) => {
+        this.options.principal = res.list;
+      });
+    },
+    // 选择工厂
+    change_factoryId() {
+      this.form.parentId = '';
+      this.form.groupId = '';
+      this.options.workshop = [];
+      this.getListWorkshopByParentId();
+    },
+    // 选择负责人部门
+    change_principalDep() {
+      this.form.extInfo.principal = '';
+      this.options.principal = [];
+      this.getUserPage();
+    },
+    // 选择车间
+    change_workshop() {
+      let result = this.options.workshop.find(
+        (n) => n.id == this.form.parentId
+      );
+      this.form.groupId = result.groupId;
+    },
+    // 选择负责人
+    change_principal() {
+      let result = this.options.principal.find(
+        (n) => n.id == this.form.extInfo.principal
+      );
+      this.form.extInfo.phone = result.phone;
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.location-warp {
+  display: flex;
+  .detail {
+    margin-left: 10px;
+  }
+}
+</style>

+ 100 - 0
src/views/factoryModel/productionLine/components/search.vue

@@ -0,0 +1,100 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="15">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="产线编码:">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="产线名称:">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+          <el-button @click="reset">重置</el-button>
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
+  data() {
+    // 默认表单数据
+    const defaultWhere = {
+      code: '',
+      name: ''
+    };
+    return {
+      defaultWhere,
+      // 表单数据
+      where: { ...defaultWhere },
+      options: {
+        groupId: []
+      }
+    };
+  },
+  computed: {
+    // 是否开启响应式布局
+    styleResponsive() {
+      return this.$store.state.theme.styleResponsive;
+    }
+  },
+  methods: {
+    /* 搜索 */
+    search() {
+      this.$emit('search', this.where);
+    },
+    /*  重置 */
+    reset() {
+      console.log(this.defaultWhere);
+      this.where = { ...this.defaultWhere };
+      this.search();
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.groupId = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    }
+  }
+};
+</script>

+ 211 - 0
src/views/factoryModel/productionLine/index.vue

@@ -0,0 +1,211 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <search
+        ref="search"
+        @search="search"
+        :options_groupId="dict.groupId"
+        :options_factory="dict.factory"
+      ></search>
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        cache-key="systemRoleTable"
+      >
+        <!-- 表头工具栏 -->
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit('add')"
+          >
+            添加
+          </el-button>
+        </template>
+        <template v-slot:workshop="{ row }">
+          {{ showWorkshop(row) }}
+        </template>
+        <template v-slot:factory="{ row }">
+          {{ showgfactory(row) }}
+        </template>
+        <template v-slot:enabled="{ row }">
+          {{ dict.enabled[row.enabled] }}
+        </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="remove(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="edit"
+      @done="done"
+      :options_groupId="dict.groupId"
+      :options_factory="dict.factory"
+    ></edit>
+  </div>
+</template>
+<script>
+import search from './components/search.vue';
+import edit from './components/edit.vue';
+import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
+import { listOrganizations } from '@/api/system/organization';
+export default {
+  components: {
+    search,
+    edit
+  },
+  data() {
+    return {
+      columns: [
+        {
+          width: 45,
+          type: 'index',
+          columnKey: 'index',
+          align: 'center'
+        },
+        {
+          prop: 'code',
+          label: '产线编码'
+        },
+        {
+          label: '产线名称',
+          prop: 'name'
+        },
+        {
+          label: '所属工厂',
+          prop: 'extInfo.factoryId',
+          slot: 'factory'
+        },
+        {
+          label: '所属车间',
+          prop: 'parentId',
+          slot: 'workshop'
+        },
+        {
+          label: '省/市/区',
+          prop: 'extInfo.location'
+        },
+        {
+          label: '详细地址',
+          prop: 'extInfo.locationDetail'
+        },
+        {
+          label: '状态',
+          prop: 'enabled',
+          slot: 'enabled'
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 220,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      dict: {
+        groupId: [],
+        factory: [],
+        enabled: {
+          1: '生效',
+          0: '未生效'
+        }
+      }
+    };
+  },
+  created() {
+    this.getGs();
+    this.getFactoryarea();
+  },
+  methods: {
+    datasource({ page, where, limit }) {
+      return getFactoryarea({
+        ...where,
+        pageNum: page,
+        size: limit,
+        type: 4
+      });
+    },
+    search(where) {
+      this.$refs.table.reload({
+        where: where,
+        page: 1
+      });
+    },
+    openEdit(type, row) {
+      this.$refs.edit.open(type, row);
+    },
+    // 获取公司数据
+    getGs() {
+      listOrganizations().then((list) => {
+        console.log(list);
+        this.dict.groupId = list;
+      });
+    },
+    // 回显工厂名称
+    showgfactory(row) {
+      let result = row.parent.find((n) => n.id == row.extInfo.factoryId);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    // 回显车间
+    showWorkshop(row) {
+      let result = row.parent.find((n) => n.id == row.parentId);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    // 获取工厂数据
+    getFactoryarea() {
+      let par = {
+        type: 1,
+        size: 9999
+      };
+      getFactoryarea(par).then((res) => {
+        this.dict.factory = res.list;
+      });
+    },
+    remove(row) {
+      deletefactoryarea(row.id)
+        .then((message) => {
+          this.$message.success(message);
+          this.done();
+        })
+        .catch((e) => {
+          this.$message.error(e.message);
+        });
+    },
+    done() {
+      this.$refs.search.search();
+    }
+  }
+};
+</script>

+ 257 - 0
src/views/factoryModel/station/components/edit.vue

@@ -0,0 +1,257 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <el-dialog
+    class="ele-dialog-form"
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    width="1000px"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-row>
+        <el-col :span="8">
+          <el-form-item
+            label="工厂编码:"
+            prop="code"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.code"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item
+            label="工厂名称:"
+            prop="name"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.name"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item
+            label="所属公司:"
+            prop="groupId"
+            style="margin-bottom: 22px"
+          >
+            <ele-tree-select
+              clearable
+              :data="options.groupId"
+              v-model="form.groupId"
+              valueKey="id"
+              labelKey="name"
+              placeholder="请选择"
+              default-expand-all
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="16" style="margin-bottom: 22px">
+          <el-form-item label="地址:" prop="location_city">
+            <div class="location-warp">
+              <el-cascader
+                clearable
+                style="width: 385px"
+                v-model="form.location"
+                :options="options.cityDataLabel"
+              ></el-cascader>
+              <el-input
+                class="detail"
+                clearable
+                :maxlength="20"
+                v-model="form.locationDetail"
+                placeholder="请输入详细地址"
+              />
+            </div>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-bottom: 22px">
+          <el-form-item label="状态:" prop="enabled">
+            <div class="location-warp">
+              <el-select
+                v-model="form.enabled"
+                v
+                placeholder="请选择"
+                style="width: 100%"
+              >
+                <el-option
+                  v-for="item in options.zt"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                >
+                </el-option>
+              </el-select>
+            </div>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button type="primary" :loading="loading" @click="save">
+        保存
+      </el-button>
+    </template>
+  </el-dialog>
+</template>
+
+<script>
+import { cityDataLabel } from 'ele-admin/packages/utils/regions';
+import { listOrganizations } from '@/api/system/organization';
+import { saveOrUpdate } from '@/api/factoryModel';
+export default {
+  data() {
+    const defaultForm = {
+      id: '',
+      code: '',
+      name: '',
+      groupId: '',
+      locationDetail: '',
+      location: [],
+      enabled: 1,
+      parentId: '',
+      type: 1 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm },
+      // 表单验证规则
+      rules: {
+        code: [{ required: true, message: '请输入', trigger: 'blur' }],
+        name: [{ required: true, message: '请输入', trigger: 'blur' }],
+        groupId: [{ required: true, message: '请输入', trigger: 'blur' }]
+      },
+      visible: false,
+      type: '', // add/edit
+      loading: false,
+      options: {
+        zt: [
+          {
+            label: '生效',
+            value: 1
+          },
+          {
+            label: '未生效',
+            value: 0
+          }
+        ],
+        groupId: [],
+        cityDataLabel
+      }
+    };
+  },
+  computed: {
+    title() {
+      switch (this.type) {
+        case 'add':
+          return '新增工厂';
+          break;
+        case 'edit':
+          return '编辑工厂';
+          break;
+        default:
+          break;
+      }
+    }
+  },
+  created() {
+    this.getGs();
+  },
+  methods: {
+    open(type, row) {
+      this.type = type;
+      this.visible = true;
+      if (type == 'edit') {
+        this.form.id = row.id;
+        this.form.code = row.code;
+        this.form.name = row.name;
+        this.form.groupId = row.groupId;
+        this.form.enabled = row.enabled;
+        this.form.parentId = row.parentId;
+        this.form.type = row.type;
+        this.form.location = row.extInfo.location.split('/');
+        this.form.locationDetail = row.extInfo.locationDetail;
+      }
+    },
+    /* 保存编辑 */
+    save() {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+        this.loading = true;
+
+        const data = {
+          code: this.form.code,
+          name: this.form.name,
+          groupId: this.form.groupId,
+          enabled: this.form.enabled,
+          parentId: this.form.groupId,
+          type: this.form.type,
+          extInfo: this.setLocation()
+        };
+        if (this.type == 'edit') {
+          data.id = this.form.id;
+        }
+        console.log(data);
+        saveOrUpdate(data)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.handleClose();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+            this.$message.error(e.message);
+          });
+      });
+    },
+    restForm() {
+      this.$refs.form.clearValidate();
+      this.form = { ...this.defaultForm };
+    },
+    handleClose() {
+      this.restForm();
+      this.visible = false;
+    },
+    // 获取公司数据
+    getGs() {
+      listOrganizations().then((list) => {
+        console.log(list);
+        this.options.groupId = this.$util.toTreeData({
+          data: list,
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+      });
+    },
+    setLocation() {
+      return {
+        location: this.form.location.join('/'),
+        locationDetail: this.form.locationDetail
+      };
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.location-warp {
+  display: flex;
+  .detail {
+    margin-left: 10px;
+  }
+}
+</style>

+ 100 - 0
src/views/factoryModel/station/components/search.vue

@@ -0,0 +1,100 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="15">
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="工厂编码:">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="工厂名称:">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="状态:">
+          <el-select
+            v-model="where.enable"
+            class="m-2"
+            placeholder="请选择"
+            size="large"
+          >
+            <el-option
+              v-for="item in options.state"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            />
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+          <el-button @click="reset">重置</el-button>
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+export default {
+  data() {
+    // 默认表单数据
+    const defaultWhere = {
+      code: '',
+      name: '',
+      enable: ''
+    };
+    return {
+      defaultWhere,
+      // 表单数据
+      where: { ...defaultWhere },
+      options: {
+        state: [
+          {
+            label: '生效',
+            value: 1
+          },
+          {
+            label: '失效',
+            value: 0
+          }
+        ]
+      }
+    };
+  },
+  computed: {
+    // 是否开启响应式布局
+    styleResponsive() {
+      return this.$store.state.theme.styleResponsive;
+    }
+  },
+  methods: {
+    /* 搜索 */
+    search() {
+      this.$emit('search', this.where);
+    },
+    /*  重置 */
+    reset() {
+      console.log(this.defaultWhere);
+      this.where = { ...this.defaultWhere };
+      this.search();
+    }
+  }
+};
+</script>

+ 172 - 0
src/views/factoryModel/station/index.vue

@@ -0,0 +1,172 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <search ref="search" @search="search"></search>
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        cache-key="systemRoleTable"
+      >
+        <!-- 表头工具栏 -->
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit('add')"
+          >
+            添加
+          </el-button>
+        </template>
+        <template v-slot:enabled="{ row }">
+          {{ dict.enabled[row.enabled] }}
+        </template>
+        <template v-slot:groupId="{ row }">
+          {{ showgroupName(row.groupId) }}
+        </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="remove(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="edit" @done="done"></edit>
+  </div>
+</template>
+<script>
+import search from './components/search.vue';
+import edit from './components/edit.vue';
+import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
+import { listOrganizations } from '@/api/system/organization';
+export default {
+  components: {
+    search,
+    edit
+  },
+  data() {
+    return {
+      columns: [
+        {
+          width: 45,
+          type: 'index',
+          columnKey: 'index',
+          align: 'center'
+        },
+        {
+          prop: 'code',
+          label: '工厂编码'
+        },
+        {
+          label: '工厂名称',
+          prop: 'name'
+        },
+        {
+          label: '所属公司',
+          prop: 'groupId',
+          slot: 'groupId'
+        },
+        {
+          label: '省/市/区',
+          prop: 'extInfo.location'
+        },
+        {
+          label: '详细地址',
+          prop: 'extInfo.locationDetail'
+        },
+        {
+          label: '状态',
+          prop: 'enabled',
+          slot: 'enabled'
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 220,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      dict: {
+        enabled: {
+          1: '生效',
+          0: '未生效'
+        },
+        groupId: []
+      }
+    };
+  },
+  created() {
+    this.getGs();
+  },
+  methods: {
+    datasource({ page, where, limit }) {
+      return getFactoryarea({
+        ...where,
+        pageNum: page,
+        size: limit,
+        type: 1
+      });
+    },
+    search(where) {
+      this.$refs.table.reload({
+        where: where,
+        page: 1
+      });
+    },
+    openEdit(type, row) {
+      this.$refs.edit.open(type, row);
+    },
+    // 获取公司数据
+    getGs() {
+      listOrganizations().then((list) => {
+        console.log(list);
+        this.dict.groupId = list;
+      });
+    },
+    // 回显公司名称
+    showgroupName(id) {
+      let result = this.dict.groupId.find((n) => n.id == id);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    remove(row) {
+      deletefactoryarea(row.id)
+        .then((message) => {
+          this.$message.success(message);
+          this.done();
+        })
+        .catch((e) => {
+          this.$message.error(e.message);
+        });
+    },
+    done() {
+      this.$refs.search.search();
+    }
+  }
+};
+</script>

+ 232 - 0
src/views/factoryModel/workshop/components/edit.vue

@@ -0,0 +1,232 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <el-dialog
+    class="ele-dialog-form"
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    width="800px"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-row>
+        <el-col :span="12">
+          <el-form-item
+            label="车间编码:"
+            prop="code"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.code"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item
+            label="车间名称:"
+            prop="name"
+            style="margin-bottom: 22px"
+          >
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.name"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item
+            label="所属公司:"
+            prop="groupId"
+            style="margin-bottom: 22px"
+          >
+            <ele-tree-select
+              clearable
+              :data="options.groupId"
+              v-model="form.groupId"
+              valueKey="id"
+              labelKey="name"
+              placeholder="请选择"
+              default-expand-all
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12" style="margin-bottom: 22px">
+          <el-form-item label="所属工厂:" prop="location_city">
+            <el-select
+              v-model="form.parentId"
+              placeholder="请选择"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options_factory"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12" style="margin-bottom: 22px">
+          <el-form-item label="地址:" prop="location_city">
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.extInfo.location"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button type="primary" :loading="loading" @click="save">
+        保存
+      </el-button>
+    </template>
+  </el-dialog>
+</template>
+
+<script>
+import { saveOrUpdate } from '@/api/factoryModel';
+export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
+  data() {
+    const defaultForm = {
+      id: '',
+      code: '',
+      name: '',
+      extInfo: {
+        location: ''
+      },
+      groupId: '',
+      enabled: 1,
+      parentId: '',
+      type: 3 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm },
+      // 表单验证规则
+      rules: {
+        code: [{ required: true, message: '请输入', trigger: 'blur' }],
+        name: [{ required: true, message: '请输入', trigger: 'blur' }],
+        groupId: [{ required: true, message: '请输入', trigger: 'blur' }],
+        parentId: [{ required: true, message: '请输入', trigger: 'blur' }]
+      },
+      visible: false,
+      type: '', // add/edit
+      loading: false,
+      options: {
+        groupId: []
+      }
+    };
+  },
+  computed: {
+    title() {
+      switch (this.type) {
+        case 'add':
+          return '新增车间';
+          break;
+        case 'edit':
+          return '编辑车间';
+          break;
+        default:
+          break;
+      }
+    }
+  },
+  methods: {
+    open(type, row) {
+      this.type = type;
+      this.visible = true;
+      if (type == 'edit') {
+        for (const key of Object.keys(this.form)) {
+          if (key !== 'extInfo') {
+            this.form[key] = row[key];
+          } else {
+            for (const el of Object.keys(this.form.extInfo)) {
+              this.form.extInfo[el] = row.extInfo[el];
+            }
+          }
+        }
+      }
+    },
+    /* 保存编辑 */
+    save() {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+        this.loading = true;
+
+        if (this.type == 'add') {
+          delete this.form.id;
+        }
+
+        saveOrUpdate(this.form)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.handleClose();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+            this.$message.error(e.message);
+          });
+      });
+    },
+    restForm() {
+      this.$refs.form.clearValidate();
+      this.form = { ...this.defaultForm };
+    },
+    handleClose() {
+      this.restForm();
+      this.visible = false;
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.groupId = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.location-warp {
+  display: flex;
+  .detail {
+    margin-left: 10px;
+  }
+}
+</style>

+ 132 - 0
src/views/factoryModel/workshop/components/search.vue

@@ -0,0 +1,132 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="15">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="车间编码:">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="车间名称:">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="所属公司:">
+          <ele-tree-select
+            clearable
+            :data="options.groupId"
+            v-model="where.groupId"
+            valueKey="id"
+            labelKey="name"
+            placeholder="请选择"
+            default-expand-all
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="所属工厂:">
+          <el-select
+            v-model="where.parentId"
+            placeholder="请选择"
+            style="width: 100%"
+          >
+            <el-option
+              v-for="item in options_factory"
+              :key="item.id"
+              :label="item.name"
+              :value="item.id"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+          <el-button @click="reset">重置</el-button>
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
+  data() {
+    // 默认表单数据
+    const defaultWhere = {
+      code: '',
+      name: '',
+      groupId: '',
+      parentId: ''
+    };
+    return {
+      defaultWhere,
+      // 表单数据
+      where: { ...defaultWhere },
+      options: {
+        groupId: []
+      }
+    };
+  },
+  computed: {
+    // 是否开启响应式布局
+    styleResponsive() {
+      return this.$store.state.theme.styleResponsive;
+    }
+  },
+  methods: {
+    /* 搜索 */
+    search() {
+      this.$emit('search', this.where);
+    },
+    /*  重置 */
+    reset() {
+      console.log(this.defaultWhere);
+      this.where = { ...this.defaultWhere };
+      this.search();
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.groupId = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    }
+  }
+};
+</script>

+ 195 - 0
src/views/factoryModel/workshop/index.vue

@@ -0,0 +1,195 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <search
+        ref="search"
+        @search="search"
+        :options_groupId="dict.groupId"
+        :options_factory="dict.factory"
+      ></search>
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        cache-key="systemRoleTable"
+      >
+        <!-- 表头工具栏 -->
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit('add')"
+          >
+            添加
+          </el-button>
+        </template>
+        <template v-slot:groupId="{ row }">
+          {{ showgroupName(row.groupId) }}
+        </template>
+        <template v-slot:factory="{ row }">
+          {{ showgfactory(row.parentId) }}
+        </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="remove(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="edit"
+      @done="done"
+      :options_groupId="dict.groupId"
+      :options_factory="dict.factory"
+    ></edit>
+  </div>
+</template>
+<script>
+import search from './components/search.vue';
+import edit from './components/edit.vue';
+import { getFactoryarea, deletefactoryarea } from '@/api/factoryModel';
+import { listOrganizations } from '@/api/system/organization';
+export default {
+  components: {
+    search,
+    edit
+  },
+  data() {
+    return {
+      columns: [
+        {
+          width: 45,
+          type: 'index',
+          columnKey: 'index',
+          align: 'center'
+        },
+        {
+          prop: 'code',
+          label: '车间编码'
+        },
+        {
+          label: '车间名称',
+          prop: 'name'
+        },
+        {
+          label: '所属公司',
+          prop: 'groupId',
+          slot: 'groupId'
+        },
+        {
+          label: '所属工厂',
+          prop: 'parentId',
+          slot: 'factory'
+        },
+        {
+          label: '详细地址',
+          prop: 'extInfo.location'
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 220,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      dict: {
+        groupId: [],
+        factory: []
+      }
+    };
+  },
+  created() {
+    this.getGs();
+    this.getFactoryarea();
+  },
+  methods: {
+    datasource({ page, where, limit }) {
+      return getFactoryarea({
+        ...where,
+        pageNum: page,
+        size: limit,
+        type: 3
+      });
+    },
+    search(where) {
+      this.$refs.table.reload({
+        where: where,
+        page: 1
+      });
+    },
+    openEdit(type, row) {
+      this.$refs.edit.open(type, row);
+    },
+    // 获取公司数据
+    getGs() {
+      listOrganizations().then((list) => {
+        console.log(list);
+        this.dict.groupId = list;
+      });
+    },
+    // 回显公司名称
+    showgroupName(id) {
+      let result = this.dict.groupId.find((n) => n.id == id);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    // 回显工厂名称
+    showgfactory(id) {
+      let result = this.dict.factory.find((n) => n.id == id);
+      if (result) {
+        return result.name;
+      } else {
+        return '';
+      }
+    },
+    // 获取工厂数据
+    getFactoryarea() {
+      let par = {
+        type: 1,
+        size: 9999
+      };
+      getFactoryarea(par).then((res) => {
+        this.dict.factory = res.list;
+      });
+    },
+    remove(row) {
+      deletefactoryarea(row.id)
+        .then((message) => {
+          this.$message.success(message);
+          this.done();
+        })
+        .catch((e) => {
+          this.$message.error(e.message);
+        });
+    },
+    done() {
+      this.$refs.search.search();
+    }
+  }
+};
+</script>

+ 463 - 465
src/views/ledgerAssets/equipment/edit.vue

@@ -456,498 +456,496 @@
 </template>
 
 <script>
-  import DeptSelect from '@/components/CommomSelect/dept-select.vue';
-  // import selectUpload from "@/components/selectUpload";
-  // import UploadImg from "@/components/uploadImg/WithView.vue";
-  import DialogGoods from './components/DialogGoods';
-  // import { parseTime } from "@/utils/ruoyi.js";
-  // import org from "@/api/main/org";
-  // import user from "@/api/main/user";
-  // import selectTree from "@/components/selectTree";
-  // import dict from "@/api/main/craft/dict";
-  // import { imageView } from "@/utils";
-  // import {
-  //   getPlants,
-  //   getfactoryInfo,
-  //   getFactorys,
-  //   getProductionLine,
-  //   saveOrEdit,
-  //   getAssetNum,
-  //   getDetail,
-  //   getSupplier
-  // } from '@/api/ledgerAssets/equipment';
-  import { getFactoryarea } from '@/api/factoryModel/factoryManagement';
-  import { saveOrEdit, getAssetInfo } from '@/api/ledgerAssets';
-  import { getUserPage } from '@/api/system/organization';
-  export default {
-    components: {
-      //selectUpload,
-      //UploadImg,
-      DialogGoods,
-      DeptSelect
-    },
-    data () {
-      return {
-        title: '新建设备信息',
-        pageType: 'add',
-        btnLoading: false,
-        // 设备主键id
-        id: '',
-        form: {
-          extInfoSelf: [],
-          // 基本信息
-          code: '',
-          name: '',
-          productTime: ''
-        },
-        rules: {
-          name: [
-            { required: true, message: '请输入设备名称', trigger: 'blur' }
-          ],
-          code: [{ required: true, message: '请输入设备编码', trigger: 'blur' }]
-        },
+import DeptSelect from '@/components/CommomSelect/dept-select.vue';
+// import selectUpload from "@/components/selectUpload";
+// import UploadImg from "@/components/uploadImg/WithView.vue";
+import DialogGoods from './components/DialogGoods';
+// import { parseTime } from "@/utils/ruoyi.js";
+// import org from "@/api/main/org";
+// import user from "@/api/main/user";
+// import selectTree from "@/components/selectTree";
+// import dict from "@/api/main/craft/dict";
+// import { imageView } from "@/utils";
+// import {
+//   getPlants,
+//   getfactoryInfo,
+//   getFactorys,
+//   getProductionLine,
+//   saveOrEdit,
+//   getAssetNum,
+//   getDetail,
+//   getSupplier
+// } from '@/api/ledgerAssets/equipment';
+import { getFactoryarea } from '@/api/factoryModel';
+import { saveOrEdit, getAssetInfo } from '@/api/ledgerAssets';
+import { getUserPage } from '@/api/system/organization';
+export default {
+  components: {
+    //selectUpload,
+    //UploadImg,
+    DialogGoods,
+    DeptSelect
+  },
+  data() {
+    return {
+      title: '新建设备信息',
+      pageType: 'add',
+      btnLoading: false,
+      // 设备主键id
+      id: '',
+      form: {
+        extInfoSelf: [],
         // 基本信息
-        basicInfo: {},
-        // 资产信息
-        zcInfo: {
-          // 	固定资产编码
-          fixCode: '',
-          // 颜色
-          color: '',
-          // 重量
-          weight: '',
-          // 维护部门code
-          repairGroupId: '',
-          repairDeptName: '',
-          repairUserId: '',
-          // 权属部门
-          ownershipGroupId: '',
-          ownershipUserId: '',
-          // 设备用途
-          purpose: '',
-          //品牌
-          brand: '',
-          // 	供应商code
-          supplierId: '',
-          // 详细地址
-          detailLocation: '',
-          // 请选择产线
-          lineCode: '',
-          // 请选择车间
-          workshopCode: '',
-          // 请选择工厂
-          factoryCode: '',
-          // 厂房
-          factoryPlantCode: '',
-          roteCode: ''
-        },
-        // 图片
-        imageUrl: null,
-        // 文档信息
-        attUrl: {
-          operatingManual: null,
-          productionLicence: null,
-          explosionProofCertificate: null,
-          surveyReport: null,
-          inspectionCycleManual: null,
-          informationDrawing: null,
-          productCertificate: null
-        },
-        // 是否开始物联
-        isIotEnable: true,
-        // 物联ID
-        iotId: '',
-        // 回显过保时间
-        cbexpirationTime: '',
-        // 生命周期
-        sourceDICT: '',
-        // 网络状态
-        networkStatus: '',
-        options: {
-          deptList: [],
-          repairUserId: [],
-          ownershipUserId: [],
-          supplierId: [],
-          factoryCode: [],
-          workshopCode: [],
-          lineCode: [],
-          factoryPlantCode: [],
-          brand: []
-        }
-      };
-    },
-    watch: {
-      'zcInfo.factoryCode': function (nVal) {
-        if (this.pageType == 'add') {
-          this.zcInfo.workshopCode = '';
-          this.options.workshopCode = [];
-        }
-
-        // 获取车间
-        this.getFactorys();
+        code: '',
+        name: '',
+        productTime: ''
       },
-      'zcInfo.workshopCode': function (nVal) {
-        if (this.pageType == 'add') {
-          this.zcInfo.lineCode = '';
-          this.options.lineCode = [];
-        }
-        // 获取产线
-        this.getProductionLine();
+      rules: {
+        name: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
+        code: [{ required: true, message: '请输入设备编码', trigger: 'blur' }]
+      },
+      // 基本信息
+      basicInfo: {},
+      // 资产信息
+      zcInfo: {
+        // 	固定资产编码
+        fixCode: '',
+        // 颜色
+        color: '',
+        // 重量
+        weight: '',
+        // 维护部门code
+        repairGroupId: '',
+        repairDeptName: '',
+        repairUserId: '',
+        // 权属部门
+        ownershipGroupId: '',
+        ownershipUserId: '',
+        // 设备用途
+        purpose: '',
+        //品牌
+        brand: '',
+        // 	供应商code
+        supplierId: '',
+        // 详细地址
+        detailLocation: '',
+        // 请选择产线
+        lineCode: '',
+        // 请选择车间
+        workshopCode: '',
+        // 请选择工厂
+        factoryCode: '',
+        // 厂房
+        factoryPlantCode: '',
+        roteCode: ''
+      },
+      // 图片
+      imageUrl: null,
+      // 文档信息
+      attUrl: {
+        operatingManual: null,
+        productionLicence: null,
+        explosionProofCertificate: null,
+        surveyReport: null,
+        inspectionCycleManual: null,
+        informationDrawing: null,
+        productCertificate: null
+      },
+      // 是否开始物联
+      isIotEnable: true,
+      // 物联ID
+      iotId: '',
+      // 回显过保时间
+      cbexpirationTime: '',
+      // 生命周期
+      sourceDICT: '',
+      // 网络状态
+      networkStatus: '',
+      options: {
+        deptList: [],
+        repairUserId: [],
+        ownershipUserId: [],
+        supplierId: [],
+        factoryCode: [],
+        workshopCode: [],
+        lineCode: [],
+        factoryPlantCode: [],
+        brand: []
       }
-      // "zcInfo.repairGroupId": function (nVal) {
-      //   this.zcInfo.repairUserId = "";
-      //   this.options.repairUserId = [];
-      // },
-      // "zcInfo.ownershipDeptCode": function (nVal) {
-      //   this.zcInfo.ownershipUserId = "";
-      //   this.options.ownershipUserId = [];
-      // },
-    },
-    computed: {
-      // 过保时间
-      expirationTime () {
-        if (this.form.productTime && this.basicInfo.expirationDate) {
-          return this.setGbTime(
-            this.form.productTime,
-            this.basicInfo.expirationDate,
-            this.basicInfo.expirationDateUnit
-          );
-        } else {
-          return '';
-        }
+    };
+  },
+  watch: {
+    'zcInfo.factoryCode': function (nVal) {
+      if (this.pageType == 'add') {
+        this.zcInfo.workshopCode = '';
+        this.options.workshopCode = [];
       }
+
+      // 获取车间
+      this.getFactorys();
     },
-    created () {
-      if (this.$route.query.id) {
-        this.pageType = 'edit';
-        this.id = this.$route.query.id;
-        this.getInfo();
-        this.title = '编辑设备信息';
+    'zcInfo.workshopCode': function (nVal) {
+      if (this.pageType == 'add') {
+        this.zcInfo.lineCode = '';
+        this.options.lineCode = [];
+      }
+      // 获取产线
+      this.getProductionLine();
+    }
+    // "zcInfo.repairGroupId": function (nVal) {
+    //   this.zcInfo.repairUserId = "";
+    //   this.options.repairUserId = [];
+    // },
+    // "zcInfo.ownershipDeptCode": function (nVal) {
+    //   this.zcInfo.ownershipUserId = "";
+    //   this.options.ownershipUserId = [];
+    // },
+  },
+  computed: {
+    // 过保时间
+    expirationTime() {
+      if (this.form.productTime && this.basicInfo.expirationDate) {
+        return this.setGbTime(
+          this.form.productTime,
+          this.basicInfo.expirationDate,
+          this.basicInfo.expirationDateUnit
+        );
+      } else {
+        return '';
+      }
+    }
+  },
+  created() {
+    if (this.$route.query.id) {
+      this.pageType = 'edit';
+      this.id = this.$route.query.id;
+      this.getInfo();
+      this.title = '编辑设备信息';
+    }
+    // this.getTreeList();
+    // this.getgys();
+    // //this.getGxlist();
+    // this.getPlants();
+    this.getfactoryInfo();
+  },
+  methods: {
+    setImgs(type, sort, info) {
+      if (info[0]) {
+        this.attUrl[type] = info[0];
+        this.attUrl[type].sort = sort;
+      } else {
+        this.attUrl[type] = null;
       }
-      // this.getTreeList();
-      // this.getgys();
-      // //this.getGxlist();
-      // this.getPlants();
-      this.getfactoryInfo();
     },
-    methods: {
-      setImgs (type, sort, info) {
-        if (info[0]) {
-          this.attUrl[type] = info[0];
-          this.attUrl[type].sort = sort;
-        } else {
-          this.attUrl[type] = null;
-        }
-      },
-      handlwpbm () {
-        this.$refs.DialogGoods.open();
-      },
-      async cbDialogGoods (data) {
-        this.basicInfo = data;
-        this.form.rootCategoryLevelId = JSON.parse(
-          this.basicInfo.categoryLevelPathId || '[]'
-        )[0];
-        this.form.categoryId = this.basicInfo.id;
-        this.form.name = this.basicInfo.name;
-        // let res = await getAssetNum({
-        //   assetCode: this.basicInfo.code,
-        //   num: 1
-        // });
-        this.form.code = Date.now(); //res.data[0].onlyCode;
-      },
-      // 计算过保时间
-      setGbTime (basic, value, type) {
-        basic = Date.parse(basic);
-        let time;
-        switch (type) {
-          case 'minute':
-            time = value * 1000 * 60;
-            break;
-          case 'hour':
-            time = value * 1000 * 60 * 60;
-            break;
-          case 'day':
-            time = value * 1000 * 60 * 60 * 24;
-            break;
-          case 'month':
-            time = value * 1000 * 60 * 60 * 24 * 30;
-            break;
-          case 'year':
-            time = value * 1000 * 60 * 60 * 24 * 365;
-            break;
-          default:
-            break;
-        }
+    handlwpbm() {
+      this.$refs.DialogGoods.open();
+    },
+    async cbDialogGoods(data) {
+      this.basicInfo = data;
+      this.form.rootCategoryLevelId = JSON.parse(
+        this.basicInfo.categoryLevelPathId || '[]'
+      )[0];
+      this.form.categoryId = this.basicInfo.id;
+      this.form.name = this.basicInfo.name;
+      // let res = await getAssetNum({
+      //   assetCode: this.basicInfo.code,
+      //   num: 1
+      // });
+      this.form.code = Date.now(); //res.data[0].onlyCode;
+    },
+    // 计算过保时间
+    setGbTime(basic, value, type) {
+      basic = Date.parse(basic);
+      let time;
+      switch (type) {
+        case 'minute':
+          time = value * 1000 * 60;
+          break;
+        case 'hour':
+          time = value * 1000 * 60 * 60;
+          break;
+        case 'day':
+          time = value * 1000 * 60 * 60 * 24;
+          break;
+        case 'month':
+          time = value * 1000 * 60 * 60 * 24 * 30;
+          break;
+        case 'year':
+          time = value * 1000 * 60 * 60 * 24 * 365;
+          break;
+        default:
+          break;
+      }
 
-        let num = basic + time;
-        return parseTime(num);
-      },
-      async getwhbm () {
-        if (!this.zcInfo.repairGroupId) return;
-        let data = await getUserPage({
-          pageNum: 1,
-          size: 9999,
-          groupId: this.zcInfo.repairGroupId
-        });
-        this.options.repairUserId = data.list;
-      },
-      async getqsbm () {
-        if (!this.zcInfo.ownershipGroupId) return;
-        let data = await getUserPage({
-          pageNum: 1,
-          size: 9999,
-          groupId: this.zcInfo.ownershipGroupId
-        });
-        this.options.ownershipUserId = data.list;
-      },
-      // 树形结构数据
-      getTreeList () {
-        org.tree().then((res) => {
-          this.options.deptList = res.data;
-        });
-      },
-      // 获取供应商、工序列表
-      async getgys () {
-        let muster = await getSupplier({
-          size: 999
-        });
-        this.options.supplierId = muster.data.items; //供应商
-      },
-      // 获取工序列表
-      async getGxlist () {
-        // let data = await dict.list({
-        //   size: 999
-        // });
-        // this.options.roteCode = data.data.items;
-      },
-      // 获取厂房列表
-      async getPlants () {
-        // let data = await getPlants({
-        //   size: 999
-        // });
-        // this.options.factoryPlantCode = data.data.items;
-      },
-      // 获取工厂列表
-      async getfactoryInfo () {
-        let data = await getFactoryarea({
-          size: 999,
-          type: 1,
-          enable: 1
-        });
-        this.options.factoryCode = data.list;
-      },
-      // 获取车间列表
-      async getFactorys () {
-        // let data = await getFactorys({
-        //   factoryCode: this.zcInfo.factoryCode,
-        //   size: 999
-        // });
-        // this.options.workshopCode = data.data.items;
-      },
-      // 获取产线列表
-      async getProductionLine () {
-        // let data = await getProductionLine({
-        //   factory: this.zcInfo.factoryCode,
-        //   workshopId: this.zcInfo.workshopCode,
-        //   size: 999
-        // });
-        // this.options.lineCode = data.data.items;
-      },
-      // 选择图片回调
-      cbUploadImg (data) {
-        if (data.length > 0) {
-          this.imageUrl = data[0];
+      let num = basic + time;
+      return parseTime(num);
+    },
+    async getwhbm() {
+      if (!this.zcInfo.repairGroupId) return;
+      let data = await getUserPage({
+        pageNum: 1,
+        size: 9999,
+        groupId: this.zcInfo.repairGroupId
+      });
+      this.options.repairUserId = data.list;
+    },
+    async getqsbm() {
+      if (!this.zcInfo.ownershipGroupId) return;
+      let data = await getUserPage({
+        pageNum: 1,
+        size: 9999,
+        groupId: this.zcInfo.ownershipGroupId
+      });
+      this.options.ownershipUserId = data.list;
+    },
+    // 树形结构数据
+    getTreeList() {
+      org.tree().then((res) => {
+        this.options.deptList = res.data;
+      });
+    },
+    // 获取供应商、工序列表
+    async getgys() {
+      let muster = await getSupplier({
+        size: 999
+      });
+      this.options.supplierId = muster.data.items; //供应商
+    },
+    // 获取工序列表
+    async getGxlist() {
+      // let data = await dict.list({
+      //   size: 999
+      // });
+      // this.options.roteCode = data.data.items;
+    },
+    // 获取厂房列表
+    async getPlants() {
+      // let data = await getPlants({
+      //   size: 999
+      // });
+      // this.options.factoryPlantCode = data.data.items;
+    },
+    // 获取工厂列表
+    async getfactoryInfo() {
+      let data = await getFactoryarea({
+        size: 999,
+        type: 1,
+        enable: 1
+      });
+      this.options.factoryCode = data.list;
+    },
+    // 获取车间列表
+    async getFactorys() {
+      // let data = await getFactorys({
+      //   factoryCode: this.zcInfo.factoryCode,
+      //   size: 999
+      // });
+      // this.options.workshopCode = data.data.items;
+    },
+    // 获取产线列表
+    async getProductionLine() {
+      // let data = await getProductionLine({
+      //   factory: this.zcInfo.factoryCode,
+      //   workshopId: this.zcInfo.workshopCode,
+      //   size: 999
+      // });
+      // this.options.lineCode = data.data.items;
+    },
+    // 选择图片回调
+    cbUploadImg(data) {
+      if (data.length > 0) {
+        this.imageUrl = data[0];
+      } else {
+        this.imageUrl = '';
+      }
+    },
+    // 添加自定义参数
+    addItem() {
+      if (this.form.extInfoSelf.length < 10) {
+        let item = { key: '', value: '' };
+        this.form.extInfoSelf.push(item);
+      } else {
+        this.$message.warning('自定义参数最多添加10条');
+      }
+    },
+    // 删除自定义参数
+    delt(item, index) {
+      this.form.extInfoSelf.splice(index, 1);
+    },
+    // 提交
+    submit() {
+      if (!this.basicInfo && this.pageType == 'add') {
+        return this.$message.error('请选择物品编码');
+      }
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          let par = {
+            //基本信息
+            ...this.form,
+            // id: this.basicInfo.id,
+            // assetCode: this.form.code,
+            // assetName: this.form.name,
+            assetType: 1,
+            // informationId: this.basicInfo.id,
+            // productTime: this.form.productTime,
+            // expirationTime: this.expirationTime,
+            // 资产信息
+            positionIds: '1,1,1,1',
+            ...this.zcInfo,
+            // 文档信息
+            attUrl: this.setWd() || [],
+            // // 设备图片
+            imageUrl: this.imageUrl || {},
+            // 是否启用物联
+            isIotEnable: this.isIotEnable
+            // // 扩展字段
+            // extInfoSelf: this.setKz()
+          };
+          if (this.pageType == 'edit') {
+            par.id = this.id;
+          }
+          this.btnLoading = true;
+          saveOrEdit(par)
+            .then((res) => {
+              this.$message.success('操作成功');
+              this.$router.go(-1);
+            })
+            .finally(() => {
+              this.btnLoading = false;
+            });
         } else {
-          this.imageUrl = '';
+          console.log('error submit!!');
+          return false;
         }
-      },
-      // 添加自定义参数
-      addItem () {
-        if (this.form.extInfoSelf.length < 10) {
-          let item = { key: '', value: '' };
-          this.form.extInfoSelf.push(item);
+      });
+    },
+    // 处理扩展字段
+    setKz() {
+      return this.form.extInfoSelf || [];
+    },
+    // 处理文档信息
+    setWd() {
+      let attUrl = [];
+      Object.entries(this.attUrl).forEach(([key, value], index) => {
+        if (value) {
+          attUrl.push(value);
         } else {
-          this.$message.warning('自定义参数最多添加10条');
+          attUrl.push({ sort: index + 1 });
         }
-      },
-      // 删除自定义参数
-      delt (item, index) {
-        this.form.extInfoSelf.splice(index, 1);
-      },
-      // 提交
-      submit () {
-        if (!this.basicInfo && this.pageType == 'add') {
-          return this.$message.error('请选择物品编码');
-        }
-        this.$refs.form.validate((valid) => {
-          if (valid) {
-            let par = {
-              //基本信息
-              ...this.form,
-              // id: this.basicInfo.id,
-              // assetCode: this.form.code,
-              // assetName: this.form.name,
-              assetType: 1,
-              // informationId: this.basicInfo.id,
-              // productTime: this.form.productTime,
-              // expirationTime: this.expirationTime,
-              // 资产信息
-              positionIds: '1,1,1,1',
-              ...this.zcInfo,
-              // 文档信息
-              attUrl: this.setWd() || [],
-              // // 设备图片
-              imageUrl: this.imageUrl || {},
-              // 是否启用物联
-              isIotEnable: this.isIotEnable
-              // // 扩展字段
-              // extInfoSelf: this.setKz()
-            };
-            if (this.pageType == 'edit') {
-              par.id = this.id;
-            }
-            this.btnLoading = true;
-            saveOrEdit(par)
-              .then((res) => {
-                this.$message.success('操作成功');
-                this.$router.go(-1);
-              })
-              .finally(() => {
-                this.btnLoading = false;
-              });
-          } else {
-            console.log('error submit!!');
-            return false;
-          }
-        });
-      },
-      // 处理扩展字段
-      setKz () {
-        return this.form.extInfoSelf || [];
-      },
-      // 处理文档信息
-      setWd () {
-        let attUrl = [];
-        Object.entries(this.attUrl).forEach(([key, value], index) => {
-          if (value) {
-            attUrl.push(value);
-          } else {
-            attUrl.push({ sort: index + 1 });
+      });
+      return attUrl;
+    },
+    // 获取设备详情
+    async getInfo() {
+      const data = await getAssetInfo(this.id);
+      this.form = data;
+      this.basicInfo = data.category;
+      this.cbexpirationTime = data.expirationTime;
+      this.sourceDICT = data.sourceDICT;
+      this.networkStatus = data.networkStatus;
+      // 资产信息
+      for (const key of Object.keys(this.zcInfo)) {
+        console.log(key, data[key]);
+        this.zcInfo[key] = data[key];
+      }
+      this.getwhbm();
+      this.getqsbm();
+      if (data.attUrl && data.attUrl.length > 0) {
+        // 文档信息
+        Object.keys(this.attUrl).forEach((n, index) => {
+          if (data.attUrl[index].accessUrl) {
+            this.attUrl[n] = data.attUrl[index];
           }
         });
-        return attUrl;
-      },
-      // 获取设备详情
-      async getInfo () {
-        const data = await getAssetInfo(this.id);
-        this.form = data;
-        this.basicInfo = data.category;
-        this.cbexpirationTime = data.expirationTime;
-        this.sourceDICT = data.sourceDICT;
-        this.networkStatus = data.networkStatus;
-        // 资产信息
-        for (const key of Object.keys(this.zcInfo)) {
-          console.log(key, data[key]);
-          this.zcInfo[key] = data[key];
-        }
-        this.getwhbm();
-        this.getqsbm();
-        if (data.attUrl && data.attUrl.length > 0) {
-          // 文档信息
-          Object.keys(this.attUrl).forEach((n, index) => {
-            if (data.attUrl[index].accessUrl) {
-              this.attUrl[n] = data.attUrl[index];
-            }
-          });
-        }
+      }
 
-        // 设备图片
-        this.imageUrl = data.imageUrl;
-        if (this.imageUrl) {
-          // imageView(this.imageUrl).then((res) => {
-          //   this.$refs.UploadImg.setImg(res);
-          // });
-        }
-        // 物联参数
-        this.isIotEnable = data.isIotEnable;
-        this.iotId = data.iotId;
-      },
-      // 设置标准产能
-      setbzcn (val) {
-        if (!val) {
-          return '';
-        }
-        let item = JSON.parse(val);
-        return item.standardCapacity || '';
-      },
-      hanldFactoryCode () {
-        // 重置
-        this.zcInfo.workshopCode = '';
-        this.zcInfo.lineCode = '';
-        this.options.workshopCode = [];
-        this.options.lineCode = [];
-        // 获取车间
-        this.getFactorys();
-      },
-      hanldWorkshopCode () {
-        // 重置
-        this.options.workshopCode = [];
-        this.options.lineCode = [];
-        // 获取产线
-        this.getProductionLine();
+      // 设备图片
+      this.imageUrl = data.imageUrl;
+      if (this.imageUrl) {
+        // imageView(this.imageUrl).then((res) => {
+        //   this.$refs.UploadImg.setImg(res);
+        // });
       }
+      // 物联参数
+      this.isIotEnable = data.isIotEnable;
+      this.iotId = data.iotId;
+    },
+    // 设置标准产能
+    setbzcn(val) {
+      if (!val) {
+        return '';
+      }
+      let item = JSON.parse(val);
+      return item.standardCapacity || '';
+    },
+    hanldFactoryCode() {
+      // 重置
+      this.zcInfo.workshopCode = '';
+      this.zcInfo.lineCode = '';
+      this.options.workshopCode = [];
+      this.options.lineCode = [];
+      // 获取车间
+      this.getFactorys();
+    },
+    hanldWorkshopCode() {
+      // 重置
+      this.options.workshopCode = [];
+      this.options.lineCode = [];
+      // 获取产线
+      this.getProductionLine();
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .baseinfo-container .basic-details-title {
-    font-size: 16px;
-    margin: 15px 0;
-  }
-  .equipment-container {
-    // .content {
-    //   padding: 0 20px;
-    // }
-    .label-none {
-      .el-form-item__content {
-        margin-left: 0 !important;
-      }
-    }
-    .upload-container {
-      display: flex;
-      .file-list {
-        margin-left: 50px;
-        flex: 1;
-      }
+.baseinfo-container .basic-details-title {
+  font-size: 16px;
+  margin: 15px 0;
+}
+.equipment-container {
+  // .content {
+  //   padding: 0 20px;
+  // }
+  .label-none {
+    .el-form-item__content {
+      margin-left: 0 !important;
     }
   }
-  .sbwz {
-    .item {
-      width: 120px;
-    }
-    .item + .item {
-      margin-left: 10px;
-    }
-    .item-input {
-      width: 350px;
+  .upload-container {
+    display: flex;
+    .file-list {
+      margin-left: 50px;
+      flex: 1;
     }
   }
-  .input {
-    width: 202px;
+}
+.sbwz {
+  .item {
+    width: 120px;
   }
-  .kzzd {
-    width: 500px;
-    .add-col {
-      display: flex;
-      .col-input {
-        & + .col-input {
-          margin-left: 10px;
-        }
-      }
-      .del {
+  .item + .item {
+    margin-left: 10px;
+  }
+  .item-input {
+    width: 350px;
+  }
+}
+.input {
+  width: 202px;
+}
+.kzzd {
+  width: 500px;
+  .add-col {
+    display: flex;
+    .col-input {
+      & + .col-input {
         margin-left: 10px;
       }
     }
+    .del {
+      margin-left: 10px;
+    }
   }
+}
 </style>