loulijun2021
2022-06-27 2cb8775339209916fcc889dfa9d5ea7a9f63cd24
仓库定义、库位定义、物料类型  实现增删查改功能
已修改8个文件
2419 ■■■■■ 文件已修改
src/api/zzmx.js 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/jcsz/jsqd.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/template.vue 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wlgl/ckdy.vue 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wlgl/kwdy.vue 510 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/zzmx/chda.vue 1190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/zzmx/gylx.vue 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/zzmx/wllx.vue 481 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/zzmx.js
@@ -182,3 +182,58 @@
    data
  })
}
// 工序关联缺陷查询
export function StepAssociationDefect(data) {
  return request({
    url: 'BasicSetting/StepAssociationDefect',
    method: 'get',
    params: data
  })
}
// 工序关联缺陷提交
export function SaveStepAssociationDefect(stepcode, data) {
  return request({
    url: 'BasicSetting/SaveStepAssociationDefect?stepcode=' + stepcode,
    method: 'post',
    data
  })
}
// 产品信息下拉框查询
export function PartSelect() {
  return request({
    url: 'BasicSetting/PartSelect',
    method: 'get'
  })
}
// 产品编码查找工艺路线下拉框
export function PartSelectRpute(data) {
  return request({
    url: 'BasicSetting/PartSelectRpute',
    method: 'get',
    params: data
  })
}
// 根据工艺路线编码查找关联工序集合
export function RouteSelectStep(data) {
  return request({
    url: 'BasicSetting/RouteSelectStep',
    method: 'get',
    params: data
  })
}
// 根据工序线编码查找关联设备集合
export function StepSelectEqp(data) {
  return request({
    url: 'BasicSetting/StepSelectEqp',
    method: 'get',
    params: data
  })
}
// 节拍工价查询
export function BeatRateSearch(data) {
  return request({
    url: 'BasicSetting/BeatRateSearch',
    method: 'get',
    params: data
  })
}
src/views/jcsz/jsqd.vue
@@ -243,7 +243,6 @@
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="{row}">
            <div class="operationClass">
              <el-button v-if="row.isVisible===0" type="text" @click="delSetting(row)">删除</el-button>
@@ -251,12 +250,6 @@
              <el-button v-if="row.isVisible===1" type="text" @click="formSettingCancel(row)">取消</el-button>
            </div>
          </template>
          <!--          <template v-for="item in RoleTypeCodeArr" slot-scope="{row}">-->
          <!--            <div :key="item.roletype_code" class="operationClass">-->
          <!--              <el-button v-if="item.isVisible" type="text" @click="formSettingSave(row)">保存</el-button>-->
          <!--              <el-button v-if="item.isVisible" type="text" @click="formSettingCancel(row)">取消</el-button>-->
          <!--            </div>-->
          <!--          </template>-->
        </el-table-column>
      </el-table>
      <!--分页-->
@@ -845,7 +838,7 @@
      }
      const res = await RoleTypeAdd([data])
      if (res.code === '200') {
        this.$message.success('添加成功!')
        this.$message.success('保存成功!')
        await this.getRoleTypeSearch()
      }
    },
src/views/template.vue
@@ -20,9 +20,9 @@
              <el-select v-model="form.OrgType" :popper-append-to-body="false" style="width: 200px" placeholder="请选择">
                <el-option
                  v-for="item in OrgTypeArr"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
@@ -106,7 +106,7 @@
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-button type="text" @click="edit('edit',row)">修改</el-button>
                <el-button type="text" @click="del(row.id)">删除</el-button>
                <el-button type="text" @click="del(row)">删除</el-button>
              </div>
            </template>
          </el-table-column>
@@ -150,8 +150,9 @@
          >
            <el-option
              v-for="item in SupUnitArr"
              :label="item.org_name"
              :value="item.id"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
@@ -207,7 +208,7 @@
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 10 // 每页多少条
        rows: 20 // 每页多少条
      },
      OrgTypeArr: [
        { label: '工厂', value: 'F' },
@@ -303,13 +304,13 @@
      })
    },
    // 删除按钮
    async del(id) {
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: id }).then(res => {
        DeleteOrganization({ orgid: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getOrganizationSearch()
@@ -336,10 +337,8 @@
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            OrganType: this.dialogFormOrgTypeSelected,
            OrganCode: this.dialogForm.OrgCode,
            OrganName: this.dialogForm.OrgName,
            SupUnit: this.dialogFormOrgTypeSelected === 'F' ? '0' : this.dialogForm.SupUnit,
            OperType: this.operation === 'add' ? 'Add' : 'Update',
            Operator: getCookie('admin')
          }
src/views/wlgl/ckdy.vue
@@ -86,7 +86,7 @@
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-button type="text" @click="edit('edit',row)">修改</el-button>
                <el-button type="text" @click="del(row.id)">删除</el-button>
                <el-button type="text" @click="del(row)">删除</el-button>
              </div>
            </template>
          </el-table-column>
@@ -114,14 +114,14 @@
      @close="handleClose"
    >
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
        <el-form-item label="仓库编码" prop="OrgCode">
          <el-input v-model="dialogForm.OrgCode" :disabled="operation!=='add'" style="width: 220px" />
        <el-form-item label="仓库编码" prop="warehousecode">
          <el-input v-model="dialogForm.warehousecode" :disabled="operation!=='add'" style="width: 220px" />
        </el-form-item>
        <el-form-item label="仓库名称" prop="OrgName">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        <el-form-item label="仓库名称" prop="warehousename">
          <el-input v-model="dialogForm.warehousename" style="width: 220px" />
        </el-form-item>
        <el-form-item label="仓库描述" prop="SupUnit">
          <el-input v-model="dialogForm.OrgName" type="textarea" style="width: 220px" />
        <el-form-item label="仓库描述">
          <el-input v-model="dialogForm.description" type="textarea" style="width: 220px" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
@@ -136,9 +136,7 @@
<script>
import Pagination from '@/components/Pagination'
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
import { WareHouseDefSearch } from '@/api/wlgl'
import { AddUpdateWareHouseDef, DeleteWareHouseDef, WareHouseDefSearch } from '@/api/wlgl'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
@@ -158,13 +156,6 @@
        }
      }
    }
    const validateTypeCode = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请选择上级'))
      } else {
        callback()
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
@@ -176,31 +167,27 @@
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 10 // 每页多少条
        rows: 20 // 每页多少条
      },
      total: 10,
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        OrgType: '',
        OrgCode: '',
        OrgName: ''
        id: '',
        warehousecode: '',
        warehousename: '',
        description: '',
        OperType: ''
      },
      dialogFormOrgTypeSelected: '',
      operation: '',
      dialogFormRules: {
        OrgType: [
          { required: true, message: '请输入选择类型', trigger: ['blur', 'change'] }
        ],
        OrgCode: [
        warehousecode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
        ],
        OrgName: [
        warehousename: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        ],
        SupUnit: [
          { required: true, validator: validateTypeCode, trigger: ['blur', 'change'] }
        ]
      }
    }
@@ -255,21 +242,21 @@
    edit(operation, row) {
      this.operation = operation
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
        this.dialogForm.id = row.id
        this.dialogForm.warehousecode = row.code
        this.dialogForm.warehousename = row.name
        this.dialogForm.description = row.description
      })
    },
    // 删除按钮
    async del(id) {
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: id }).then(res => {
        DeleteWareHouseDef({ warehousecode: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getWareHouseDefSearch()
@@ -281,10 +268,9 @@
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.OrgType = ''
      this.dialogForm.OrgCode = ''
      this.dialogForm.OrgName = ''
      this.dialogForm.SupUnit = ''
      this.dialogForm.warehousecode = ''
      this.dialogForm.warehousename = ''
      this.dialogForm.description = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
@@ -296,14 +282,13 @@
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            OrganType: this.dialogFormOrgTypeSelected,
            OrganCode: this.dialogForm.OrgCode,
            OrganName: this.dialogForm.OrgName,
            SupUnit: this.dialogFormOrgTypeSelected === 'F' ? '0' : this.dialogForm.SupUnit,
            OperType: this.operation === 'add' ? 'Add' : 'Update',
            Operator: getCookie('admin')
            'id': this.dialogForm.id,
            'warehousecode': this.dialogForm.warehousecode,
            'warehousename': this.dialogForm.warehousename,
            'description': this.dialogForm.description,
            'OperType': this.operation === 'add' ? 'Add' : 'Update'
          }
          AddUpdateOrganization(data).then(res => {
          AddUpdateWareHouseDef(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
src/views/wlgl/kwdy.vue
@@ -1,11 +1,515 @@
<template />
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div style="padding: 10px 5px 0 0">
        <el-form
          ref="form"
          :model="form"
          label-width="80px"
          inline
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm">
            <el-form-item label="库位编码" style=" display: flex;">
              <el-input v-model="form.storagecode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="库位名称" style=" display: flex;">
              <el-input v-model="form.storagename" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="库位描述" style=" display: flex;">
              <el-input v-model="form.description" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="创建人员" style=" display: flex;">
              <el-input v-model="form.createuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item label="所属仓库" style=" display: flex;">
              <el-select v-model="form.stockcode" :popper-append-to-body="false" style="width: 200px" placeholder="请选择">
                <el-option
                  v-for="item in stockArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
            <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
      </div>
      <el-divider />
      <div style="margin-left: 10px;display: flex">
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>
      </div>
      <el-divider />
      <div class="elTableDiv">
        <el-table
          :data="tableData"
          border
          :height="tableHeight"
          :style="{width: 100+'%',height:tableHeight+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
        >
          <!--          <el-table-column-->
          <!--            type="selection"-->
          <!--            width="50"-->
          <!--          />-->
          <el-table-column
            prop="RowNum"
            width="50"
            label="序号"
          />
          <el-table-column
            prop="code"
            label="库位编码"
            sortable="custom"
          />
          <el-table-column
            prop="name"
            label="库位名称"
            sortable="custom"
          />
          <el-table-column
            prop="description"
            label="库位描述"
            sortable="custom"
          />
          <el-table-column
            prop="stock_name"
            label="所属仓库"
            sortable="custom"
          />
          <el-table-column
            prop="lm_user"
            label="创建人员"
            sortable="custom"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            sortable="custom"
          />
          <el-table-column
            label="操作"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-button type="text" @click="edit('edit',row)">修改</el-button>
                <el-button type="text" @click="del(row)">删除</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getStorageDefSearch"
      />
    </div>
    <el-dialog
      :title="operation==='add'?'新增':'修改'"
      :visible.sync="dialogVisible"
      width="50%"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
        <el-form-item label="库位编码" prop="storagecode">
          <el-input v-model="dialogForm.storagecode" :disabled="operation!=='add'" style="width: 220px" />
        </el-form-item>
        <el-form-item label="库位名称" prop="storagename">
          <el-input v-model="dialogForm.storagename" style="width: 220px" />
        </el-form-item>
        <el-form-item label="所属库位" prop="stockcode">
          <el-select
            v-model="dialogForm.stockcode"
            :popper-append-to-body="false"
            style="width: 220px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in stockArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="库位描述">
          <el-input v-model="dialogForm.description" type="textarea" style="width: 220px" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { AddUpdateStorageDef, DeleteStorageDef, StorageDefSearch, WareHouseDefSearch, WareHouseSelect } from '@/api/wlgl'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'Wldy'
  name: 'Zzjg',
  components: {
    Pagination
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
      form: {
        storagecode: '', // 库位编码
        storagename: '', // 库位名称
        description: '', // 库位描述
        createuser: '', // 创建人员
        stockcode: '', // 所属仓库编码
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      total: 10,
      stockArr: [], // 所属仓库数组
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        'id': '',
        'storagecode': '',
        'storagename': '',
        'description': '',
        'stockcode': '',
        'OperType': ''
      },
      operation: '',
      dialogFormRules: {
        storagecode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
        ],
        storagename: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        ],
        stockcode: [
          { required: true, message: '请选择所属库位', trigger: ['blur', 'change'] }
        ]
      }
    }
  },
  created() {
    this.getStorageDefSearch()
    this.getWareHouseSelect()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    async getStorageDefSearch() {
      const res = await StorageDefSearch(this.form)
      this.tableData = res.data
      this.total = res.count
    },
    async getWareHouseSelect() {
      const { data: res } = await WareHouseSelect()
      this.stockArr = res
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getStorageDefSearch()
    },
    // 查询
    search() {
      this.getStorageDefSearch()
    },
    upload() {
    },
    // 重置
    reset() {
      this.form.storagecode = ''
      this.form.storagename = ''
      this.form.description = ''
      this.form.createuser = ''
      this.form.stockcode = ''
      this.getStorageDefSearch()
    },
    // 新增按钮
    add(operation) {
      this.operation = operation
      this.dialogVisible = true
    },
    // 修改按钮
    edit(operation, row) {
      this.operation = operation
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.id = row.id
        this.dialogForm.storagecode = row.code
        this.dialogForm.storagename = row.name
        this.dialogForm.description = row.description
        this.dialogForm.stockcode = row.stock_code
      })
    },
    // 删除按钮
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteStorageDef({ storagecode: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getStorageDefSearch()
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.storagecode = ''
      this.dialogForm.storagename = ''
      this.dialogForm.description = ''
      this.dialogForm.stockcode = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            'id': this.dialogForm.id,
            'storagecode': this.dialogForm.storagecode,
            'storagename': this.dialogForm.storagename,
            'description': this.dialogForm.description,
            'stockcode': this.dialogForm.stockcode,
            'OperType': this.operation === 'add' ? 'Add' : 'Update'
          }
          AddUpdateStorageDef(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.getStorageDefSearch()
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
          })
        }
      })
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 250
        this.tableHeight = this.mainHeight - 100
      })
    }
  }
}
</script>
<style scoped>
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--primary {
  background-color: $main_color !important;
  height: 30px;
  display: flex;
  align-items: center;
  //border: 1px solid $main_color;
  border: none;
  padding: 0 20px;
}
::v-deep .el-button--primary:hover {
  border: none;
}
::v-deep .el-button--info {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: $main_color !important;
}
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
.footerButton {
  display: flex;
  justify-content: end;
}
::v-deep .el-button--default {
  background-color: #ffffff !important;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
::v-deep .el-button--default:hover {
  color: #606266;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
  background-color: $main_color;
  border-color: $main_color;
}
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color !important;
}
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
  border-color: $main_color;
  background-color: $main_color;
}
::v-deep .el-input__inner {
  height: 30px;
  line-height: 30px;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .cell {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
::v-deep .el-button--text {
  color: $main_color;
  font-size: 14px;
  cursor: pointer;
}
.operationClass {
  height: 23px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.el-icon-share {
  color: $main_color;
  cursor: pointer;
}
.el-checkbox.is-bordered.is-checked {
  border-color: $main_color;
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
  border-color: $main_color;
  background: $main_color;
}
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  border-color: $main_color;
  background: $main_color;
}
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
  color: $main_color !important;
}
::v-deep .el-checkbox.is-bordered + .el-checkbox.is-bordered {
  margin: 10px 30px 0px 0;
}
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color;
}
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0px 0;
}
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-input__inner:focus {
  border-color: $main_color;
}
::v-deep .el-textarea__inner:focus {
  border-color: $main_color;
}
::v-deep .el-select .el-input__inner:focus {
  border-color: $main_color;
}
::v-deep .el-select-dropdown__item.selected {
  color: $main_color;
}
</style>
src/views/zzmx/chda.vue
@@ -1,11 +1,1195 @@
<template />
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div style="padding: 10px 5px 0 0">
        <el-form
          ref="form"
          :model="form"
          label-width="80px"
          inline
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm">
            <el-form-item label="物料编码" style=" display: flex;">
              <el-input v-model="form.partcode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="物料名称" style=" display: flex;">
              <el-input v-model="form.partname" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="物料规格" style=" display: flex;">
              <el-input v-model="form.partspec" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="存货类型" style=" display: flex;">
              <el-select
                v-model="form.stocktypecode"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in stocktypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="物料类型" style=" display: flex;">
              <el-select
                v-model="form.materialtypecode"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in materialtypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="所属仓库" style=" display: flex;">
              <el-select
                v-model="form.storehousecode"
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in storehouseArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
            <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
      </div>
      <el-divider />
      <div style="margin-left: 10px;display: flex">
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button type="primary" icon="el-icon-office-building" @click="office">单位</el-button>
        <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>
      </div>
      <el-divider />
      <div class="elTableDiv">
        <el-table
          :data="tableData"
          border
          :height="tableHeight"
          :style="{width: 100+'%',height:tableHeight+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
        >
          <!--          <el-table-column-->
          <!--            type="selection"-->
          <!--            width="50"-->
          <!--          />-->
          <el-table-column
            prop="RowNum"
            width="50"
            label="序号"
          />
          <el-table-column
            prop="partcode"
            label="物料编码"
            sortable="custom"
          />
          <el-table-column
            prop="partname"
            label="物料名称"
            sortable="custom"
          />
          <el-table-column
            prop="partspec"
            label="物料规格"
            sortable="custom"
          />
          <el-table-column
            prop="uom_name"
            label="单位"
            width="120"
            sortable="custom"
          />
          <el-table-column
            prop="stocktypename"
            label="存货类型"
            sortable="custom"
          />
          <el-table-column
            prop="materialtypename"
            label="物料类别"
            sortable="custom"
          />
          <el-table-column
            prop="stck_name"
            label="仓库名称"
            sortable="custom"
          />
          <el-table-column
            prop="maxqty"
            label="库存上限"
            width="120"
            sortable="custom"
          />
          <el-table-column
            prop="minqty"
            label="库存下限"
            width="120"
            sortable="custom"
          />
          <el-table-column
            prop="lm_user"
            label="创建人员"
            sortable="custom"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            show-overflow-tooltip
            sortable="custom"
          />
          <el-table-column
            label="工艺路线"
            width="80"
          >
            <template slot-scope="{row}">
              <div class="operationClass" style="justify-content: center;width: 100%">
                <i class="el-icon-share" @click="routeClick(row)" />
                <!--                <el-button type="text" @click="edit('edit',row)">修改</el-button>-->
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getInventoryFileSelect"
      />
    </div>
    <!--新增编辑对话框-->
    <el-dialog
      :title="operation==='add'?'新增':'修改'"
      :visible.sync="dialogVisible"
      width="50%"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
        <el-form-item label="物料编码" prop="OrgCode">
          <el-input v-model="dialogForm.OrgCode" :disabled="operation!=='add'" style="width: 220px" />
        </el-form-item>
        <el-form-item label="物料名称" prop="OrgName">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        </el-form-item>
        <el-form-item label="物料规格" prop="OrgName">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        </el-form-item>
        <el-form-item label="使用单位">
          <el-select
            v-model="dialogForm.stockcode"
            :popper-append-to-body="false"
            style="width: 220px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in storehouseArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="所属仓库">
          <el-select
            v-model="dialogForm.stockcode"
            :popper-append-to-body="false"
            style="width: 220px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in storehouseArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="存货类型">
          <el-select
            v-model="dialogForm.stockcode"
            :popper-append-to-body="false"
            style="width: 220px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in stocktypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="物料类型">
          <el-select
            v-model="dialogForm.stockcode"
            :popper-append-to-body="false"
            style="width: 220px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in materialtypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="最小库存" prop="SupUnit">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        </el-form-item>
        <el-form-item label="最大库存" prop="SupUnit">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--    单位按钮对话框-->
    <el-dialog
      title="单位设置"
      :visible.sync="officeDialogVisible"
      width="50%"
      top="15vh"
      class="officeDialogVisible"
      @close="handleCloseOffice"
    >
      <div style="margin-bottom: 20px;display: flex">
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="addOffice">新增</el-button>
        <!--        <el-button type="primary" icon="el-icon-delete" @click="delSetting">删除</el-button>-->
      </div>
      <el-table
        :data="officeTableData"
        border
        highlight-current-row
        :style="{width: 100+'%',height:tableHeight-300+'px'}"
        :header-cell-style="this.$headerCellStyle"
        :cell-style="this.$cellStyle"
        @sort-change="sortChangeOfOffice"
      >
        <!--        <el-table-column-->
        <!--          type="selection"-->
        <!--          width="50"-->
        <!--        />-->
        <el-table-column
          width="50"
          label="序号"
          prop="RowNum"
        />
        <el-table-column
          prop="code"
          label="类型编码"
          sortable="custom"
        >
          <template slot-scope="{row}">
            <el-input v-if="row.isVisible===1" v-model="row.code" placeholder="请输入" />
            <div v-else> {{ row.code }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="name"
          label="类型名称"
          sortable="custom"
        >
          <template slot-scope="{row}">
            <el-input v-if="row.isVisible===1" v-model="row.name" placeholder="请输入" />
            <div v-else> {{ row.name }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="digdect"
          label="小数位数"
          sortable="custom"
        >
          <template slot-scope="{row}">
            <el-input v-if="row.isVisible===1" v-model="row.digdect" placeholder="请输入" />
            <div v-else> {{ row.digdect }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="r_ule"
          label="取整规则"
          sortable="custom"
        >
          <template slot-scope="{row}">
            <!--            <el-input v-if="row.isVisible===1" v-model="row.r_ule" placeholder="请输入" />-->
            <el-select
              v-if="row.isVisible===1"
              v-model="row.r_ule"
              :popper-append-to-body="false"
              filterable
              style="width: 200px"
              placeholder="请选择"
            >
              <el-option
                v-for="item in officeRuleArr"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
            <div v-else> {{ row.r_ule }}</div>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="{row}">
            <div class="operationClass">
              <el-button v-if="row.isVisible===0" type="text" @click="delOffice(row)">删除</el-button>
              <el-button v-if="row.isVisible===1" type="text" @click="saveOffice(row)">保存</el-button>
              <el-button v-if="row.isVisible===1" type="text" @click="cancelOffice(row)">取消</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <pagination
        v-show="officeTableDataLength>0"
        :total="officeTableDataLength"
        :page.sync="officeForm.page"
        :limit.sync="officeForm.rows"
        align="right"
        layout="prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getUomSearch"
      />
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="officeDialogVisibleCancel">返回</el-button>
          <!--          <el-button type="primary" @click="settingDialogVisibleConfirm">确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
    <!--    工艺路线对话框-->
    <el-dialog
      title="关联工艺路线"
      :visible.sync="dialogVisibleRoute"
      width="50%"
      top="15vh"
      class="dialogVisibleRoute"
      @closed="handleCloseRoute"
      @close="handleCloseRoute"
    >
      <div>
        <i class="el-icon-s-comment" style="color:#42b983;" /> 产品名称:{{ dialogFormRoute.projectName }}
      </div>
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工艺路线集合
      </div>
      <div class="myCheckboxGroup">
        <div
          v-for="item in dialogFormRoute.routeOperationArr"
          :key="item.code"
          :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
          class="myCheckbox"
          @click="myCheckboxClick(item)"
        >
          <input
            class="myCheckboxInput"
            type="checkbox"
            :value="item.code"
            :name="item.name"
            :style="{color:item.isSelected2?'#42b983':'#fff'}"
            @click="myCheckboxInputClick(item)"
          >{{ item.name }}
          <!--            父子点击事件不影响-->
          <!--            onClick="event.cancelBubble = true"-->
        </div>
      </div>
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工序列表
      </div>
      <div style="height: 400px;overflow-y: scroll">
        <el-table
          :data="projectTableData"
          border
          :height="tableHeight"
          :style="{width: 100+'%',height:tableHeight+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            prop="seq"
            width="100"
            label="工序序号"
          />
          <el-table-column
            prop="stepcode"
            label="工序编码"
          />
          <el-table-column
            prop="stepname"
            label="工序名称"
          />
          <el-table-column
            prop="enable"
            label="启用状态"
          >
            <template slot-scope="{row}">
              <div v-if="row.enable==='Y'">是</div>
              <div v-if="row.enable==='N'">否</div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="routeDialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="routeDialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import {
  AddUpdateOrganization,
  DeleteOrganization
} from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
import { WareHouseSelect } from '@/api/wlgl'
import { InventoryFileSelect, StockTypeSelect, UomAdd, UomSearch } from '@/api/zzmx'
import $ from 'jquery'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'Chda'
  name: 'Zzjg',
  components: {
    Pagination
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    const validateTypeCode = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请选择上级'))
      } else {
        callback()
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
      form: {
        partcode: '', // 物料编码
        partname: '', // 物料名称
        partspec: '', // 物料规格
        stocktypecode: '', // 存货类型编码
        materialtypecode: '', // 物料类型编码
        storehousecode: '', // 所属仓库编码
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      total: 10,
      stocktypeArr: [], // 存货类型数组
      materialtypeArr: [], // 物料类型数组
      storehouseArr: [], // 所属仓库数组
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        OrgType: '',
        OrgCode: '',
        OrgName: ''
      },
      operation: '',
      dialogFormRules: {
        OrgType: [
          { required: true, message: '请输入选择类型', trigger: ['blur', 'change'] }
        ],
        OrgCode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
        ],
        OrgName: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        ],
        SupUnit: [
          { required: true, validator: validateTypeCode, trigger: ['blur', 'change'] }
        ]
      },
      officeDialogVisible: false,
      officeForm: {
        page: 1,
        rows: 10,
        prop: 'code',
        order: 'desc'
      },
      officeRuleArr: [
        { code: 'RU', name: '向上取整' },
        { code: 'RD', name: '向下取整' },
        { code: 'RO', name: '四舍五入' }
      ],
      officeTableData: [],
      officeTableDataLength: 0,
      dialogVisibleRoute: false,
      dialogFormRoute: {
        projectName: '', // 产品名称
        projectCode: '', // 产品代码
        routeOperationArr: [] // 工艺路线集合
        // routeOperationSelectedArr: [] // 工艺路线选中集合数组
      },
      projectTableData: []// 设备列表
    }
  },
  created() {
    this.getInventoryFileSelect()
    this.getStockTypeSelect()
    this.getWareHouseSelect()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    async getInventoryFileSelect() {
      const res = await InventoryFileSelect(this.form)
      this.tableData = res.data
      this.total = res.count
    },
    async getStockTypeSelect() {
      const { data: res } = await StockTypeSelect()
      this.stocktypeArr = res
    }, async getWareHouseSelect() {
      const { data: res } = await WareHouseSelect()
      this.storehouseArr = res
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getInventoryFileSelect()
    },
    // 查询
    search() {
      this.getInventoryFileSelect()
    },
    upload() {
    },
    // 重置
    reset() {
      this.form.partcode = ''
      this.form.partname = ''
      this.form.partspec = ''
      this.form.stocktypecode = ''
      this.form.materialtypecode = ''
      this.form.storehousecode = ''
      this.getInventoryFileSelect()
    },
    // 新增按钮
    add(operation) {
      this.operation = operation
      this.dialogVisible = true
    },
    // 修改按钮
    edit(operation, row) {
      this.operation = operation
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
      })
    },
    // 删除按钮
    async del(id) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: id }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getInventoryFileSelect()
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.OrgType = ''
      this.dialogForm.OrgCode = ''
      this.dialogForm.OrgName = ''
      this.dialogForm.SupUnit = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            OrganCode: this.dialogForm.OrgCode,
            OrganName: this.dialogForm.OrgName,
            OperType: this.operation === 'add' ? 'Add' : 'Update',
            Operator: getCookie('admin')
          }
          AddUpdateOrganization(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.getInventoryFileSelect()
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
          })
        }
      })
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 250
        this.tableHeight = this.mainHeight - 100
      })
    },
    /* 点击关联工艺路线模块*/
    // 工艺路线点击
    async  routeClick(row) {
      console.log(row)
      this.dialogFormRoute.projectCode = row.partcode
      this.dialogFormRoute.projectName = row.partname
      this.dialogVisibleRoute = true
      this.dialogFormRoute.routeOperationArr = [
        { 'flag': 'Y', code: '001', name: '测试1 ',
          'Data': [
            {
              'seq': 1,
              'stepcode': 'Step01',
              'stepname': '测试工序一',
              'enable': 'Y'
            }, {
              'seq': 2,
              'stepcode': 'Step02',
              'stepname': '测试工序二',
              'enable': 'Y'
            }, {
              'seq': 3,
              'stepcode': 'Step03',
              'stepname': '测试工序三',
              'enable': 'N'
            }
          ]
        },
        { 'flag': 'N', code: '002', name: '测试2 ',
          'Data': [
            {
              'seq': 1,
              'stepcode': 'Step01',
              'stepname': '测试工序一',
              'enable': 'Y'
            }, {
              'seq': 2,
              'stepcode': 'Step02',
              'stepname': '测试工序二',
              'enable': 'Y'
            }, {
              'seq': 3,
              'stepcode': 'Step03',
              'stepname': '测试工序三',
              'enable': 'N'
            }, {
              'seq': 4,
              'stepcode': 'Step02',
              'stepname': '测试工序二',
              'enable': 'Y'
            }, {
              'seq': 5,
              'stepcode': 'Step03',
              'stepname': '测试工序三',
              'enable': 'N'
            }
          ]
        },
        { 'flag': 'N', code: '003', name: '测试3 ',
          'Data': [
            {
              'seq': 1,
              'stepcode': 'Step01',
              'stepname': '测试工序一',
              'enable': 'Y'
            }
          ]
        },
        { 'flag': 'N', code: '004', name: '测试4 ',
          'Data': [
            {
              'seq': 1,
              'stepcode': 'Step01',
              'stepname': '测试工序一',
              'enable': 'Y'
            }, {
              'seq': 2,
              'stepcode': 'Step02',
              'stepname': '测试工序二',
              'enable': 'Y'
            }
          ]
        }
      ]
      // const res = await InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode })
      // let waitFlag = false// 回显等待是否放行
      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
        item.isSelected1 = false
        item.isSelected2 = false
        if (index === 0) {
          item.isSelected1 = true
          this.projectTableData = item.Data
        }
        if (item.flag === 'Y') {
          item.isSelected2 = true
          this.$nextTick(() => {
            $('input:checkbox').eq(index).prop('checked', true)
          })
          // const interval = setInterval(() => {
          //   if ($('input:checkbox').length > 0) {
          //     waitFlag = true
          //   }
          //   if (waitFlag) {
          //     clearInterval(interval)
          //     this.$nextTick(() => {
          //       $('input:checkbox').eq(index).prop('checked', true)
          //     })
          //   }
          // }, 100)
        }
      })
    },
    // 对话框关闭
    handleCloseRoute() {
      this.dialogFormRoute.routeOperationArr = []
    },
    // 取消
    routeDialogVisibleCancel() {
    },
    // 确定
    async  routeDialogVisibleConfirm() {
      const data = []
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        if (item.isSelected2) {
          data.push({ code: item.code, name: item.name })
        }
      })
    // const res=await xxx()
    },
    // 大盒子点击事件
    myCheckboxClick(val) {
      console.log(val, 1)
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        if (val.code === item.code) {
          item.isSelected1 = true
        } else {
          item.isSelected1 = false
        }
      })
      this.projectTableData = val.Data
    },
    // 小盒子点击事件
    myCheckboxInputClick(val) {
      console.log(val, 2)
      val.isSelected2 = !val.isSelected2
    },
    /* 单位模块*/
    // 单位按钮点击事件
    office() {
      this.officeDialogVisible = true
      this.getUomSearch()
    },
    // 单位对话框关闭事件
    handleCloseOffice() {
      this.officeTableData.forEach((item, index) => {
        if (item.isVisible === 1) {
          this.officeTableData.splice(index, 1)
        }
      })
    },
    // 新增
    addOffice() {
      const data = { code: '', name: '', digdect: '', r_ule: '', isVisible: 1 }
      this.officeTableData.unshift(data)
    },
    // 删除
    delOffice(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // RoleTypeDelete({ RoleTypeCode: row.code }).then(res => {
        //   if (res.code === '200') {
        //     this.$message.success('删除成功!')
        //     this.getRoleTypeSearch()
        //   }
        // })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // 保存
    async saveOffice(row) {
      if (row.code.trim().length < 1) {
        return this.$message.info('类型编码不能为空!')
      }
      if (row.name.trim().length < 1) {
        return this.$message.info('类型名称不能为空!')
      }
      if (row.digdect.trim().length < 1) {
        return this.$message.info('小数位数不能为空!')
      }
      if (row.r_ule.trim().length < 1) {
        return this.$message.info('取整规则不能为空!')
      }
      const data = {
        code: row.code,
        name: row.name,
        digdect: row.digdect,
        r_ule: row.r_ule
      }
      const res = await UomAdd(data)
      if (res.code === '200') {
        this.$message.success('保存成功!')
        await this.getUomSearch()
      }
    },
    // 取消
    cancelOffice(row) {
      this.officeTableData.forEach((item, index) => {
        if (item.isVisible === 1 && item.code === row.code) {
          this.officeTableData.splice(index, 1)
        }
      })
    },
    // 单位列表查询
    async getUomSearch() {
      const res = await UomSearch(this.officeForm)
      this.officeTableData = res.data
      this.officeTableDataLength = res.count
      this.officeTableData.forEach(item => {
        item.isVisible = 0
      })
    },
    // 排序
    sortChangeOfOffice({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getUomSearch()
    },
    // 返回
    officeDialogVisibleCancel() {
      this.officeDialogVisible = false
    }
  }
}
</script>
<style scoped>
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--primary {
  background-color: $main_color !important;
  height: 30px;
  display: flex;
  align-items: center;
  //border: 1px solid $main_color;
  border: none;
  padding: 0 20px;
}
::v-deep .el-button--primary:hover {
  border: none;
}
::v-deep .el-button--info {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: $main_color !important;
}
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
.footerButton {
  display: flex;
  justify-content: end;
}
::v-deep .el-button--default {
  background-color: #ffffff !important;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
::v-deep .el-button--default:hover {
  color: #606266;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
.dialogVisibleRoute{
  ::v-deep .el-dialog__body {
    padding: 20px 20px !important;
  }
}
.officeDialogVisible{
  ::v-deep .el-dialog__body {
    padding: 20px 20px !important;
  }
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
  background-color: $main_color;
  border-color: $main_color;
}
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color !important;
}
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
  border-color: $main_color;
  background-color: $main_color;
}
::v-deep .el-input__inner {
  height: 30px;
  line-height: 30px;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .cell {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
::v-deep .el-button--text {
  color: $main_color;
  font-size: 14px;
  cursor: pointer;
}
.operationClass {
  height: 23px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.el-icon-share {
  color: $main_color;
  cursor: pointer;
}
.el-checkbox.is-bordered.is-checked {
  border-color: $main_color;
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
  border-color: $main_color;
  background: $main_color;
}
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  border-color: $main_color;
  background: $main_color;
}
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
  color: $main_color !important;
}
::v-deep .el-checkbox.is-bordered + .el-checkbox.is-bordered {
  margin: 10px 30px 0px 0;
}
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color;
}
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0px 0;
}
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-input__inner:focus {
  border-color: $main_color;
}
::v-deep .el-textarea__inner:focus {
  border-color: $main_color;
}
::v-deep .el-select .el-input__inner:focus {
  border-color: $main_color;
}
::v-deep .el-select-dropdown__item.selected {
  color: $main_color;
}
::v-deep .el-select .el-input .el-select__caret{
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialogVisibleRoute{
  .myCheckboxGroup {
    display: flex;
    flex-wrap: wrap;
    .myCheckbox {
      //border: 1px solid $main_color;
      border: 1px solid #eee;
      display: flex;
      min-width: 100px;
      padding: 10px;
      margin: 10px 30px 0 0;
      border-radius: 5px;
      cursor: default;
      .myCheckboxInput {
        margin: 1px 5px 0 0;
        cursor: pointer;
      }
    }
    //.myCheckbox{
    //  border: 1px solid $main_color;
    //}
    input[type=checkbox] {
      cursor: pointer;
      position: relative;
      width: 14px;
      height: 14px;
      font-size: 14px;
    }
    input[type=checkbox]::after {
      position: absolute;
      top: 0;
      //color: rgb(130, 35, 35);
      color: $main_color;
      width: 14px;
      height: 14px;
      display: inline-block;
      visibility: visible;
      padding-left: 0px;
      text-align: center;
      content: ' ';
      border-radius: 3px
    }
    input[type=checkbox]:checked::after {
      //content: "✓";
      content: "√";
      color: #fff;
      font-size: 12px;
      font-weight: bold;
      background-color: $main_color;
    }
  }
}
</style>
src/views/zzmx/gylx.vue
@@ -118,7 +118,7 @@
    <el-dialog
      :title="operation==='add'?'新增':'修改'"
      :visible.sync="dialogVisible"
      width="80%"
      width="70%"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
@@ -152,14 +152,22 @@
            <el-input v-model="dialogForm.OrgName" type="textarea" style="width: 220px" />
          </el-form-item>
        </div>
        <el-form-item label="工艺设置" prop="OrgName">
        <el-form-item label="工艺设置" prop="OrgName" style="margin-top: 30px">
          <div class="settingDiv">
            <!--   实现工艺设置动态添加-->
            <div v-for="(tag,index) in dynamicTags" :key="tag.id" style="display: flex;align-items: center">
              <div style="display: flex;align-items: center;position: relative;">
                <div class="orderNumber">{{ index }}</div>
                <div
                  class="orderNumber"
                  :style="{
                    backgroundColor:index===0?'#f8f8fa':'#409EFF',
                    color:index===0?'#c6bbc4':'#FFFFFF',
                    border:index===0?'1px solid #c6bbc4':'1px solid #409EFF',
                    zIndex:!flag&&tag.label===flagSelected?0:2
                  }"
                >
                  {{ index+1 }}</div>
                <el-tooltip class="item" effect="dark" :content="tag.label" placement="top">
                  <!--                  @close="handleTagClose(tag.label)"-->
                  <!--                  :closable="index!==0"-->
                  <el-tag
@@ -175,7 +183,15 @@
                    <i class="el-icon-edit" @click="tagEdit(tag)" />
                  </el-tag>
                </el-tooltip>
                <i v-if="index!==0" class="el-icon-close" @click="handleTagClose(tag.label)" />
                <i
                  v-if="index!==0"
                  :style="{
                    left:!flag&&tag.label===flagSelected?'191px':'91px',
                    top:!flag&&tag.label===flagSelected?'-2px':'-8px',
                  }"
                  class="el-icon-close"
                  @click="handleTagClose(tag.label)"
                />
                <el-autocomplete
                  v-if="!flag&&tag.label===flagSelected"
                  :ref="'saveTagInput'+tag.id"
@@ -256,7 +272,7 @@
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 10 // 每页多少条
        rows: 20 // 每页多少条
      },
      isEnableArr: [
        { label: '是', value: 'Y' },
@@ -318,7 +334,8 @@
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
        // return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
        return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) !== -1)
      }
    },
    loadAll() {
@@ -395,6 +412,7 @@
          this.dynamicTags.splice(index, 1)
        }
      })
      this.addDisabled = false
    },
    showInput() {
@@ -695,7 +713,18 @@
*/
.orderNumber {
  margin-bottom: 31px;
  position: absolute;
  margin-left: -7px;
  z-index: 2;
  width: 15px;
  height: 15px !important;
  font-size: 12px;
  text-align: center;
  line-height: 15px;
  color: #FFFFFF;
  background-color: #409EFF;
  border-radius: 50%;
}
.el-icon-edit {
@@ -714,17 +743,22 @@
  background-color: #99a9bf;
  color: #FFFFFF;
}
 .el-icon-close {
  position: absolute ;
  top: -5px ;
  z-index: 100 ;
.el-icon-close {
  position: absolute;
  top: -8px;
  z-index: 2;
  left: 91px;
  cursor: pointer;
  padding: 1px 0 0 1px ;
  color: #FFFFFF;
  border-radius: 50%;
  background-color: #ff7474;
  padding: 1px 0 0 1px;
}
.el-icon-close:hover {
  background-color: #99a9bf;
}
//.el-icon-close:hover {
//  background-color: #99a9bf;
//}
.el-tag--dark {
  background-color: $main_color;
@@ -746,10 +780,15 @@
  border-radius: 0;
  color: $main_color;
}
::v-deep .el-button--success:disabled {
  background-color:#eeeeee;
  color: $main_color;
}
::v-deep .el-tag {
  //height: 30px;
  border-radius: 0;
  border: 1px solid $main_color;
}
::v-deep .el-input--small .el-input__inner {
@@ -759,7 +798,8 @@
.settingDiv {
  display: flex;
  width: 100%;
  height: 40px;
  padding-left: 7px;
  height: 56px;
  overflow-x: scroll;
  overflow-y: hidden;
  align-items: center;
src/views/zzmx/wllx.vue
@@ -1,11 +1,486 @@
<template />
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div style="padding: 10px 5px 0 0">
        <el-form
          ref="form"
          :model="form"
          label-width="80px"
          inline
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm">
            <el-form-item label="类型编码" style=" display: flex;">
              <el-input v-model="form.materialtypecode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="类型名称" style=" display: flex;">
              <el-input v-model="form.materialtypename" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="存货类型" style=" display: flex;">
              <el-select v-model="form.stocktypecode" :popper-append-to-body="false" style="width: 200px" placeholder="请选择">
                <el-option
                  v-for="item in stocktypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
            <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
      </div>
      <el-divider />
      <div style="margin-left: 10px;display: flex">
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>
      </div>
      <el-divider />
      <div class="elTableDiv">
        <el-table
          :data="tableData"
          border
          :height="tableHeight"
          :style="{width: 100+'%',height:tableHeight+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
        >
          <!--          <el-table-column-->
          <!--            type="selection"-->
          <!--            width="50"-->
          <!--          />-->
          <el-table-column
            prop="RowNum"
            width="50"
            label="序号"
          />
          <el-table-column
            prop="code"
            label="物料类型编码"
            sortable="custom"
          />
          <el-table-column
            prop="name"
            label="物料类型名称"
            sortable="custom"
          />
          <el-table-column
            prop="stockname"
            label="存货类型"
            sortable="custom"
          />
          <el-table-column
            prop="lm_user"
            label="创建人员"
            sortable="custom"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            sortable="custom"
          />
          <el-table-column
            label="操作"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-button type="text" @click="edit('edit',row)">修改</el-button>
                <el-button type="text" @click="del(row)">删除</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getMaterialTypeSearch"
      />
    </div>
    <el-dialog
      :title="operation==='add'?'新增':'修改'"
      :visible.sync="dialogVisible"
      width="50%"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
        <el-form-item label="类型编码" prop="materialtypecode">
          <el-input v-model="dialogForm.materialtypecode" :disabled="operation!=='add'" style="width: 220px" />
        </el-form-item>
        <el-form-item label="类型名称" prop="materialtypename">
          <el-input v-model="dialogForm.materialtypename" style="width: 220px" />
        </el-form-item>
        <el-form-item label="存货类型" prop="stocktypecode">
          <el-select v-model="dialogForm.stocktypecode" :popper-append-to-body="false" style="width: 220px" placeholder="请选择">
            <el-option
              v-for="item in stocktypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { AddUpdateMaterialType, DeleteMaterialType, MaterialTypeSearch, StockTypeSelect } from '@/api/zzmx'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'Wllx'
  name: 'Zzjg',
  components: {
    Pagination
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
      form: {
        materialtypecode: '', // 物料类型编码
        materialtypename: '', // 物料类型名称
        stocktypecode: '', // 存货类型编码
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 10 // 每页多少条
      },
      total: 10,
      stocktypeArr: [], // 存货类型数组
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        'id': '',
        'materialtypecode': '',
        'materialtypename': '',
        'stocktypecode': '',
        'OperType': ''
      },
      operation: '',
      dialogFormRules: {
        materialtypecode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
        ],
        materialtypename: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        ],
        stocktypecode: [
          { required: true, message: '请选择存货类型', trigger: ['blur', 'change'] }
        ]
      }
    }
  },
  created() {
    this.getMaterialTypeSearch()
    this.getStockTypeSelect()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    async getMaterialTypeSearch() {
      const res = await MaterialTypeSearch(this.form)
      this.tableData = res.data
      this.total = res.count
    },
    async getStockTypeSelect() {
      const { data: res } = await StockTypeSelect()
      this.stocktypeArr = res
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getMaterialTypeSearch()
    },
    // 查询
    search() {
      this.getMaterialTypeSearch()
    },
    upload() {
    },
    // 重置
    reset() {
      this.form.materialtypecode = ''
      this.form.materialtypename = ''
      this.form.stocktypecode = ''
      this.getMaterialTypeSearch()
    },
    // 新增按钮
    add(operation) {
      this.operation = operation
      this.dialogVisible = true
    },
    // 修改按钮
    edit(operation, row) {
      this.operation = operation
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.id = row.id
        this.dialogForm.materialtypecode = row.code
        this.dialogForm.materialtypename = row.name
        this.dialogForm.stocktypecode = row.stockcode
      })
    },
    // 删除按钮
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteMaterialType({ materialtypecode: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getMaterialTypeSearch()
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.id = ''
      this.dialogForm.materialtypecode = ''
      this.dialogForm.materialtypename = ''
      this.dialogForm.stocktypecode = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            'id': this.dialogForm.id,
            'materialtypecode': this.dialogForm.materialtypecode,
            'materialtypename': this.dialogForm.materialtypename,
            'stocktypecode': this.dialogForm.stocktypecode,
            'OperType': this.operation === 'add' ? 'Add' : 'Update'
          }
          AddUpdateMaterialType(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.getMaterialTypeSearch()
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
          })
        }
      })
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 250
        this.tableHeight = this.mainHeight - 100
      })
    }
  }
}
</script>
<style scoped>
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--primary {
  background-color: $main_color !important;
  height: 30px;
  display: flex;
  align-items: center;
  //border: 1px solid $main_color;
  border: none;
  padding: 0 20px;
}
::v-deep .el-button--primary:hover {
  border: none;
}
::v-deep .el-button--info {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: $main_color !important;
}
::v-deep .el-dialog__footer {
  display: flex;
  justify-content: flex-end;
}
.footerButton {
  display: flex;
  justify-content: end;
}
::v-deep .el-button--default {
  background-color: #ffffff !important;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
::v-deep .el-button--default:hover {
  color: #606266;
}
::v-deep .el-dialog__body {
  padding: 20px 100px !important;
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
  background-color: $main_color;
  border-color: $main_color;
}
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color !important;
}
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
  border-color: $main_color;
  background-color: $main_color;
}
::v-deep .el-input__inner {
  height: 30px;
  line-height: 30px;
}
::v-deep .el-table .caret-wrapper {
  transform: scale(0.8);
}
::v-deep .cell {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
::v-deep .el-button--text {
  color: $main_color;
  font-size: 14px;
  cursor: pointer;
}
.operationClass {
  height: 23px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.el-icon-share {
  color: $main_color;
  cursor: pointer;
}
.el-checkbox.is-bordered.is-checked {
  border-color: $main_color;
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
  border-color: $main_color;
  background: $main_color;
}
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  border-color: $main_color;
  background: $main_color;
}
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
  color: $main_color !important;
}
::v-deep .el-checkbox.is-bordered + .el-checkbox.is-bordered {
  margin: 10px 30px 0px 0;
}
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: $main_color;
}
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
  margin: 10px 30px 0px 0;
}
.body ::v-deep .el-divider {
  border: 1px solid #eee;
  width: 99%;
  margin: 10px auto;
}
.body ::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-input__inner:focus {
  border-color: $main_color;
}
::v-deep .el-textarea__inner:focus{
  border-color: $main_color;
}
::v-deep .el-select .el-input__inner:focus{
  border-color: $main_color;
}
::v-deep .el-select-dropdown__item.selected{
  color: $main_color;
}
</style>