cuijian
2025-06-26 694d882c7a27bc276d37f1c06d0c67a03146e086
基础数据,产线,班次,班组
已重命名3个文件
已添加5个文件
已修改1个文件
已删除1个文件
1647 ■■■■■ 文件已修改
src/api/api.js 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/FactoryManager.vue 71 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/ShiftGroupManager.vue 501 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/ShiftManager.vue 195 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/modules/FactoryManager/FactoryEquipment.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/modules/FactoryManager/FactoryModal.vue 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/modules/group/GroupModal.vue 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/modules/group/SelectUserModal.vue 287 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/modules/shift/ShiftModel.vue 324 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/base/ShiftManager.vue 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/api.js
@@ -57,9 +57,9 @@
const queryMyDepartTreeList = (params)=>getAction("/sys/sysDepart/queryMyDeptTreeList",params);
//车间管理
const queryProductionTreeList = (params)=>getAction("/mdc/mdcProduction/queryTreeList",params);
const queryById = (params)=>getAction("/mdc/mdcProduction/queryIdTree",params);
const deleteByProduction   = (params)=>deleteAction("/mdc/mdcProduction/delete",params);
const queryFactoryTreeList = (params)=>getAction("/base/factory/queryTreeList",params);
const queryById = (params)=>getAction("/base/factory/queryIdTree",params);
const deleteByFactory   = (params)=>deleteAction("/base/factory/delete",params);
//日志管理
@@ -165,8 +165,8 @@
  queryMyDepartTreeList,
  getUserNoticeInfo,
  getDictItemsFromCache,
  queryProductionTreeList,
  deleteByProduction,
  queryFactoryTreeList,
  deleteByFactory,
  queryById,
  addEquipment,
  editEquipment
src/views/base/FactoryManager.vue
ÎļþÃû´Ó src/views/system/ProductionManager.vue ÐÞ¸Ä
@@ -38,7 +38,7 @@
            <!--@rightClick="rightHandle"-->
            <!--:selectedKeys="selectedKeys"-->
            <!--:checkedKeys="checkedKeys"-->
            <!--:treeData="departTree"-->
            <!--:treeData="factoryTree"-->
            <!--:checkStrictly="checkStrictly"-->
            <!--:expandedKeys="iExpandedKeys"-->
            <!--:autoExpandParent="autoExpandParent"-->
@@ -61,7 +61,7 @@
              @rightClick="rightHandle"
              :selectedKeys="selectedKeys"
              :checkedKeys="checkedKeys"
              :treeData="departTree"
              :treeData="factoryTree"
              :checkStrictly="checkStrictly"
              :expandedKeys="iExpandedKeys"
              :autoExpandParent="autoExpandParent"
@@ -93,11 +93,11 @@
        <a-tab-pane tab="基本信息" key="1">
          <a-card :bordered="false" v-if="selectedKeys.length>0">
            <a-form-model ref="form" :model="model" :rules="validatorRules">
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionCode" label="车间编号">
                <a-input placeholder="请输入产线/车间编号" v-model="model.productionCode"/>
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryCode" label="车间编号">
                <a-input placeholder="请输入产线/车间编号" v-model="model.factoryCode"/>
              </a-form-model-item>
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionName" label="车间名称">
                <a-input placeholder="请输入产线/车间名称" v-model="model.productionName"/>
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryName" label="车间名称">
                <a-input placeholder="请输入产线/车间名称" v-model="model.factoryName"/>
              </a-form-model-item>
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="上级车间">
                <a-tree-select
@@ -110,10 +110,10 @@
                </a-tree-select>
              </a-form-model-item>
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="排序">
                <a-input-number v-model="model.productionOrder"/>
                <a-input-number v-model="model.sorter"/>
              </a-form-model-item>
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="备注">
                <a-textarea placeholder="请输入备注" v-model="model.memo"/>
                <a-textarea placeholder="请输入备注" v-model="model.remark"/>
              </a-form-model-item>
            </a-form-model>
            <div class="anty-form-btn">
@@ -127,32 +127,29 @@
            </a-empty>
          </a-card>
        </a-tab-pane>
        <!--<a-tab-pane tab="部门权限" key="2" forceRender>-->
        <!--<depart-auth-modal ref="departAuth"/>-->
        <!--</a-tab-pane>-->
        <a-tab-pane tab="设备列表" key="2" forceRender>
          <!--<depart-auth-modal/>-->
          <production-equipment ref="departAuth"></production-equipment>
        </a-tab-pane>
        <!-- <a-tab-pane tab="设备列表" key="2" forceRender>
          <factory-equipment ref="departAuth"></factory-equipment>
        </a-tab-pane> -->
      </a-tabs>
    </a-col>
    <production-modal ref="departModal" @ok="loadTree"></production-modal>
    <factory-modal ref="departModal" @ok="loadTree"></factory-modal>
  </a-row>
</template>
<script>
  import ProductionEquipment from './modules/ProductionManager/ProductionEquipment'
  import { queryProductionTreeList, searchByKeywords, deleteByProduction } from '@/api/api'
  import FactoryEquipment from './modules/FactoryManager/FactoryEquipment'
  import { queryFactoryTreeList, searchByKeywords, deleteByFactory } from '@/api/api'
  import { httpAction, deleteAction } from '@/api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ProductionModal from './modules/ProductionManager/ProductionModal'
  import FactoryModal from './modules/FactoryManager/FactoryModal'
  export default {
    name: 'ProductionManager',
    name: 'FactoryManager',
    mixins: [JeecgListMixin],
    components: {
      ProductionEquipment,
      ProductionModal
      FactoryEquipment,
      FactoryModal
    },
    data() {
      return {
@@ -164,7 +161,7 @@
        disable: true,
        treeData: [],
        visible: false,
        departTree: [],
        factoryTree: [],
        rightClickSelectedKey: '',
        rightClickSelectedOrgCode: '',
        hiding: true,
@@ -191,14 +188,14 @@
          edges: []
        },
        validatorRules: {
          productionName: [{ required: true, message: '请输入产线/车间名称!' }]
          factoryName: [{ required: true, message: '请输入产线/车间名称!' }]
        },
        url: {
          delete: '/mdc/mdcProduction/delete',
          edit: '/mdc/mdcProduction/edit',
          deleteBatch: '/mdc/mdcProduction/deleteBatch',
          exportXlsUrl: '/mdc/mdcProduction/exportXls',
          importExcelUrl: '/mdc/mdcProduction/importExcel'
          delete: '/base/factory/delete',
          edit: '/base/factory/edit',
          deleteBatch: '/base/factory/deleteBatch',
          exportXlsUrl: '/base/factory/exportXls',
          importExcelUrl: '/base/factory/importExcel'
        },
        orgCategoryDisabled: false,
        isIncludesNotLeaf: false
@@ -216,15 +213,15 @@
      loadTree() {
        var that = this
        that.treeData = []
        that.departTree = []
        queryProductionTreeList().then((res) => {
        that.factoryTree = []
        queryFactoryTreeList().then((res) => {
          if (res.success) {
            //部门全选后,再添加部门,选中数量增多
            this.allTreeKeys = []
            for (let i = 0; i < res.result.length; i++) {
              let temp = res.result[i]
              that.treeData.push(temp)
              that.departTree.push(temp)
              that.factoryTree.push(temp)
              that.setThisExpandedKeys(temp)
              that.getAllKeys(temp)
              // console.log(temp.id)
@@ -277,7 +274,7 @@
      batchDel: function() {
        console.log(this.checkedKeys)
        this.isIncludesNotLeaf = false
        this.includesNotLeaf(this.departTree)
        this.includesNotLeaf(this.factoryTree)
        console.log('isIncludesNotLeaf', this.isIncludesNotLeaf)
        // ä¸ºtrue则表示选中项包含非叶子结点 false则表示选中项均为叶子结点
@@ -340,10 +337,10 @@
        if (value) {
          searchByKeywords({ keyWord: value }).then((res) => {
            if (res.success) {
              that.departTree = []
              that.factoryTree = []
              for (let i = 0; i < res.result.length; i++) {
                let temp = res.result[i]
                that.departTree.push(temp)
                that.factoryTree.push(temp)
              }
            } else {
              // that.$message.warning(res.message)
@@ -481,7 +478,7 @@
          this.$refs.departModal.add(this.selectedKeys)
          this.$refs.departModal.title = '新增'
        } else {
          this.$refs.departModal.add(this.rightClickSelectedKey)
          this.$refs.departModal.add(this.currSelected)
          this.$refs.departModal.title = '新增'
        }
      },
@@ -492,7 +489,7 @@
            title: '确认删除',
            content: `确定要删除 ${that.currSelected.productionName} å—?`,
            onOk: function() {
              deleteByProduction({ id: that.currSelected.id }).then((resp) => {
              deleteByFactory({ id: that.currSelected.id }).then((resp) => {
                if (resp.success) {
                  //删除成功后,去除已选中中的数据
                  // that.checkedKeys.splice(that.checkedKeys.findIndex(key => key === that.rightClickSelectedKey), 1)
src/views/base/ShiftGroupManager.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,501 @@
<template>
  <a-row :gutter="10">
    <a-col :md="leftColMd" :sm="24" style="margin-bottom: 20px">
      <a-card :bordered="false">
        <!-- æŸ¥è¯¢åŒºåŸŸ -->
        <div class="table-page-search-wrapper">
          <!-- æœç´¢åŒºåŸŸ -->
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="12" :sm="8">
                <a-form-item label="班组名称" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
                  <a-input placeholder="" v-model="queryParam.groupName"></a-input>
                </a-form-item>
              </a-col>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
            <a-col :md="12" :sm="24">
               <a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 21px">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </a-col>
          </span>
            </a-row>
          </a-form>
        </div>
        <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
        <div class="table-operator" style="margin: 5px 0 10px 2px">
          <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
        </div>
        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
          <i class="anticon anticon-info-circle ant-alert-icon">
          </i> å·²é€‰æ‹© <a><b>{{ selectedRowKeys1.length }}</b></a>项
          <a style="margin-left: 24px" @click="onClearSelected1">清空</a>
        </div>
        <div style="margin-top: 15px">
          <a-table
            style="height:500px"
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{selectedRowKeys: selectedRowKeys1, onChange: onSelectChange1, type:'radio'}"
            @change="handleTableChange">
          <span slot="action" slot-scope="text, record">
            <a @click="handleOpen(record)">人员</a>
            <a-divider type="vertical"/>
            <a-dropdown>
              <a class="ant-dropdown-link">
                æ›´å¤š <a-icon type="down"/>
              </a>
              <a-menu slot="overlay">
                <a-menu-item>
                  <a @click="handleEdit(record)">编辑</a>
                </a-menu-item>
                <a-menu-item>
                  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete1(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
        </span>
          </a-table>
        </div>
        <!-- å³ä¾§çš„角色权限配置 -->
        <group-modal ref="modalForm" @ok="modalFormOk"></group-modal>
      </a-card>
    </a-col>
    <a-col :md="rightColMd" :sm="24" v-if="this.rightcolval == 1">
      <a-card :bordered="false">
        <div style="text-align: right;">
          <a-icon type="close-circle" @click="hideUserList" />
        </div>
        <!-- æŸ¥è¯¢åŒºåŸŸ -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline">
            <a-row :gutter="24">
              <a-col :md="12" :sm="12">
                <a-form-item label="用户账号">
                  <a-input placeholder="" v-model="queryParam2.username"></a-input>
                </a-form-item>
              </a-col>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
            <a-col :md="9" :sm="24">
             <a-button type="primary" @click="searchQuery2" icon="search" style="margin-left: 21px">查询</a-button>
              <a-button type="primary" @click="searchReset2" icon="reload" style="margin-left: 8px">重置</a-button>
            </a-col>
          </span>
            </a-row>
          </a-form>
        </div>
        <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
        <div class="table-operator" :md="24" :sm="24">
          <a-button @click="handleAddUserGroup" type="primary" icon="plus" style="margin-top: 16px">添加班组人员</a-button>
          <a-dropdown v-if="selectedRowKeys2.length > 0">
            <a-menu slot="overlay">
              <a-menu-item key="1" @click="batchDel2">
                <a-icon type="delete"/>
                å–消关联
              </a-menu-item>
            </a-menu>
            <a-button style="margin-left: 8px"> æ‰¹é‡æ“ä½œ
              <a-icon type="down"/>
            </a-button>
          </a-dropdown>
        </div>
        <!-- table区域-begin -->
        <div>
          <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
            <i class="anticon anticon-info-circle ant-alert-icon"></i> å·²é€‰æ‹© <a style="font-weight: 600">{{
            selectedRowKeys2.length }}</a>项
            <a style="margin-left: 24px" @click="onClearSelected2">清空</a>
          </div>
          <a-table
            style="height:500px"
            ref="table2"
            bordered
            size="middle"
            rowKey="id"
            :columns="columns2"
            :dataSource="dataSource2"
            :pagination="ipagination2"
            :loading="loading2"
            :rowSelection="{selectedRowKeys: selectedRowKeys2, onChange: onSelectChange2}"
            @change="handleTableChange2">
           <span slot="action" slot-scope="text, record">
          <a-popconfirm title="确定取消关联吗?" @confirm="() => handleDelete2(record.id)">
                  <a>取消关联</a>
          </a-popconfirm>
        </span>
          </a-table>
        </div>
        <!-- è¡¨å•区域 -->
        <group-modal ref="modalForm" @ok="modalFormOk"></group-modal>
        <Select-User-Modal ref="selectUserModal" @selectFinished="selectOK"></Select-User-Modal>
      </a-card>
    </a-col>
  </a-row>
</template>
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { deleteAction, postAction, getAction } from '@/api/manage'
  import SelectUserModal from './modules/group/SelectUserModal'
  import GroupModal from './modules/group/GroupModal'
  import { filterObj } from '@/utils/util'
  import moment from 'moment'
  export default {
    name: 'ShiftGroupManager',
    mixins: [JeecgListMixin],
    components: {
      SelectUserModal,
      GroupModal,
      moment
    },
    data() {
      return {
        model1: {},
        model2: {},
        currentGroupId: '',
        queryParam1: {},
        queryParam2: {},
        dataSource1: [],
        dataSource2: [],
        ipagination1: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' å…±' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        ipagination2: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' å…±' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        isorter1: {
          column: 'createTime',
          order: 'desc'
        },
        isorter2: {
          column: 'createTime',
          order: 'desc'
        },
        filters1: {},
        filters2: {},
        loading1: false,
        loading2: false,
        selectedRowKeys1: [],
        selectedRowKeys2: [],
        selectionRows1: [],
        selectionRows2: [],
        test:{},
        rightcolval:0,
        columns:
          [
            {
              title: '班组编码',
              align: 'center',
              dataIndex: 'groupCode'
            },
            {
              title: '班组名称',
              align: 'center',
              dataIndex: 'groupName'
            },
            {
              title: '创建时间',
              dataIndex: 'createTime',
              align:"center",
              sorter: true,
              customRender: (text) => {
                return moment(text).format('YYYY-MM-DD')
              }
            },
            {
              title: '操作',
              dataIndex: 'action',
              align: 'center',
              scopedSlots: { customRender: 'action' }
            }
          ],
        columns2: [{
          title: '用户账号',
          align: 'center',
          dataIndex: 'username',
          width: 120
        },
          {
            title: '用户名称',
            align: 'center',
            width: 100,
            dataIndex: 'realname'
          },
          {
            title: '状态',
            align: 'center',
            width: 80,
            dataIndex: 'status_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' },
            align: 'center',
            width: 120
          }],
        // é«˜çº§æŸ¥è¯¢å‚æ•°
        superQueryParams2: '',
        // é«˜çº§æŸ¥è¯¢æ‹¼æŽ¥æ¡ä»¶
        superQueryMatchType2: 'and',
        url: {
          list: '/base/shiftGroup/list',
          delete: '/base/shiftGroup/delete',
          list2: '/sys/user/userGroupList',
          addUserGroup: '/sys/user/addBaseUserGroup',
          delete2: '/sys/user/deleteUserGroup',
          deleteBatch2: '/sys/user/deleteUserGroupBatch',
          exportXlsUrl: 'sys/role/exportXls',
          importExcelUrl: 'sys/role/importExcel'
        }
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      },
      leftColMd() {
        return this.selectedRowKeys1.length === 0 ? 24 : 12
      },
      rightColMd() {
        return this.selectedRowKeys1.length === 0 ? 0 : 12
      }
    },
    methods: {
      onSelectChange2(selectedRowKeys, selectionRows) {
        this.selectedRowKeys2 = selectedRowKeys
        this.selectionRows2 = selectionRows
      },
      onClearSelected2() {
        this.selectedRowKeys2 = []
        this.selectionRows2 = []
      },
      onClearSelected1() {
        this.selectedRowKeys1 = []
        this.selectionRows1 = []
      },
      onSelectChange1(selectedRowKeys, selectionRows) {
        this.rightcolval = 1
        this.selectedRowKeys1 = selectedRowKeys
        this.selectionRows1 = selectionRows
        this.model1 = Object.assign({}, selectionRows[0])
        this.currentGroupId = selectedRowKeys[0]
        this.loadData2()
        this.onClearSelected2()
      },
      searchQuery() {
        this.loadData(1);
        this.onClearSelected1()
        this.onClearSelected2()
      },
      searchReset() {
      this.queryParam = {}
      this.loadData(1);
      this.onClearSelected1()
      this.onClearSelected2()
    },
    modalFormOk() {
      // æ–°å¢ž/修改 æˆåŠŸæ—¶ï¼Œé‡è½½åˆ—è¡¨
      this.loadData(1);
      this.loadData2(1);
      //清空列表选中
      this.onClearSelected1()
      this.onClearSelected2()
    },
      getQueryParams2() {
        //获取查询条件
        let sqp = {}
        if (this.superQueryParams2) {
          sqp['superQueryParams'] = encodeURI(this.superQueryParams2)
          sqp['superQueryMatchType'] = this.superQueryMatchType2
        }
        var param = Object.assign(sqp, this.queryParam2, this.isorter2, this.filters2)
        param.field = this.getQueryField2()
        param.pageNo = this.ipagination2.current
        param.pageSize = this.ipagination2.pageSize
        return filterObj(param)
      },
      getQueryField2() {
        //TODO å­—段权限控制
        var str = 'id,'
        this.columns2.forEach(function(value) {
          str += ',' + value.dataIndex
        })
        return str
      },
      loadData2(arg) {
        if (!this.url.list2) {
          this.$message.error('请设置url.list2属性!')
          return
        }
        //加载数据 è‹¥ä¼ å…¥å‚æ•°1则加载第一页的内容
        if (arg === 1) {
          this.ipagination2.current = 1
        }
        if (this.currentGroupId === '') return
        let params = this.getQueryParams2()//查询条件
        params.groupId = this.currentGroupId
        this.loading2 = true
        getAction(this.url.list2, params).then((res) => {
          if (res.success) {
            this.dataSource2 = res.result.records
            this.ipagination2.total = res.result.total
          }
          this.loading2 = false
        })
      },
      handleDelete1: function(id) {
        this.handleDelete(id)
        this.dataSource2 = []
        this.currentGroupId = ''
        this.onClearSelected1()
        this.onClearSelected2()
      },
      handleDelete2: function(id) {
        if (!this.url.delete2) {
          this.$message.error('请设置url.delete2属性!')
          return
        }
        var that = this
        deleteAction(that.url.delete2, { groupId: this.currentGroupId, userId: id }).then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData2()
            this.onClearSelected2()
          } else {
            that.$message.warning(res.message)
          }
        })
      },
      batchDel2: function() {
        if (!this.url.deleteBatch2) {
          this.$message.error('请设置url.deleteBatch2属性!')
          return
        }
        if (this.selectedRowKeys2.length <= 0) {
          this.$message.warning('请选择一条记录!')
          return
        } else {
          var ids = ''
          for (var a = 0; a < this.selectedRowKeys2.length; a++) {
            ids += this.selectedRowKeys2[a] + ','
          }
          var that = this
          console.log(this.currentDeptId)
          this.$confirm({
            title: '确认取消关联',
            content: '是否删除选中数据?',
            onOk: function() {
              deleteAction(that.url.deleteBatch2, { groupId: that.currentGroupId, userIds: ids }).then((res) => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.loadData2()
                  that.onClearSelected2()
                } else {
                  that.$message.warning(res.message)
                }
              })
            }
          })
        }
      },
      selectOK(data) {
        let params = {}
        params.groupId = this.currentGroupId
        params.userIdList = []
        for (var a = 0; a < data.length; a++) {
          params.userIdList.push(data[a])
        }
        console.log(params)
        postAction(this.url.addUserGroup, params).then((res) => {
          if (res.success) {
            this.loadData2()
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
      },
      handleAddUserGroup() {
        if (this.currentGroupId == '') {
          this.$message.error('请选择一个班组!')
        } else {
          this.$refs.selectUserModal.visible = true
        }
      },
      handleOpen(record) {
        this.rightcolval = 1
        this.selectedRowKeys1 = [record.id]
        this.model1 = Object.assign({}, record)
        this.currentGroupId = record.id
        this.onClearSelected2()
        this.loadData2()
      },
      searchQuery2() {
        this.loadData2(1)
        this.onClearSelected2()
      },
      searchReset2() {
        this.queryParam2 = {}
        this.loadData2(1)
        this.onClearSelected2()
      },
      handleTableChange2(pagination, filters, sorter) {
        //分页、排序、筛选变化时触发
        //TODO ç­›é€‰
        if (Object.keys(sorter).length > 0) {
          this.isorter2.column = sorter.field
          this.isorter2.order = 'ascend' == sorter.order ? 'asc' : 'desc'
        }
        this.ipagination2 = pagination
        this.loadData2()
      },
      hideUserList(){
        //this.rightcolval = 0
        this.selectedRowKeys1 = []
      },
    }
  }
</script>
<style scoped>
@import '~@assets/less/common.less';
  /** Button按钮间距 */
  .ant-btn {
    margin-left: 8px
  }
</style>
src/views/base/ShiftManager.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,195 @@
<template>
  <a-card :bordered="false">
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-item label="班次编号">
              <j-input placeholder="请输入班次编号" v-model="queryParam.shiftCode"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-item label="班次名称">
              <j-input placeholder="请输入班次名称" v-model="queryParam.shiftName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="info" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator">
      <a-button type="primary" @click="handleAdd" icon="plus">新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div style="width: 100%;flex: 1;overflow: auto">
      <a-table ref="table" bordered size="middle" rowKey="id" :columns="columns"
               :dataSource="dataSource" :pagination="false" class="j-table-force-nowrap" :loading="loading">
         <span
           slot="shiftStatus"
           slot-scope="text, record"
         >
           <span v-if="text == 0" style="color:red;">停用</span>
           <span v-if="text == 1" style="color:green;">启用</span>
         </span>
        <span
          slot="crossDayFlag"
          slot-scope="text, record"
        >
           <span v-if="text == '1'">是</span>
           <span v-if="text == '0'">否</span>
         </span>
        <span
          slot="action"
          slot-scope="text, record"
        >
        <a  v-if="record.shiftStatus == 1" @click="handleEdit(record)">编辑</a>
            <a-divider type="vertical" v-if="record.shiftStatus == 1"/>
            <a v-if="record.shiftStatus == 0" @click="handleStatus(record.id,1)">启用</a>
            <a v-if="record.shiftStatus == 1" @click="handleStatus(record.id,0)">停用</a>
            <a-divider type="vertical" />
            <a @click="handleDelete(record.id)">删除</a>
        </span>
      </a-table>
    </div>
    <shift-model ref="modalForm" @ok="modalFormOk"></shift-model>
  </a-card>
</template>
<script>
  import {
    requestPut, putAction, deleteAction
  } from '@/api/manage'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import ShiftModel from './modules/shift/ShiftModel'
  export default {
    name: 'ShiftManager',
    mixins: [JeecgListMixin],
    components: {
      ShiftModel
    },
    props: {},
    data() {
      return {
        url: {
          list: '/base/shift/list',
          changeStatus: '/base/shift/updateStatusById',
          deleteBatch: '/base/shift/delete'
        },
        columns: [
          {
            title: '班次编号',
            align: 'center',
            dataIndex: 'shiftCode'
          },
          {
            title: '班次名称',
            align: 'center',
            dataIndex: 'shiftName'
          },
          {
            title: '开始时间',
            align: 'center',
            dataIndex: 'startTime'
          },
          {
            title: '结束时间',
            align: 'center',
            dataIndex: 'endTime'
          },
          {
            title: '工作时长',
            align: 'center',
            dataIndex: 'workHours'
          },
          {
            title: '是否跨天',
            align: 'center',
            dataIndex: 'crossDayFlag',
            scopedSlots: { customRender: 'crossDayFlag' }
          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'shiftStatus',
            scopedSlots: { customRender: 'shiftStatus' }
          },
          {
            title: '操作',
            align: 'center',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' }
          }
        ]
      }
    },
    methods: {
      handleAdd() {
        this.$refs.modalForm.add()
        this.$refs.modalForm.title = '新增班次'
        this.$refs.modalForm.disableSubmit = false
      },
      handleEdit(record) {
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = '编辑班次'
        this.$refs.modalForm.disableSubmit = true
      },
      handleDelete: function(record){
        if(!this.url.deleteBatch){
          this.$message.error("请设置url.delete属性!")
          return
        }
        var that = this;
        deleteAction(that.url.deleteBatch, {id: record}).then((res) => {
          if (res.success) {
            that.$notification.success({
              message:'消息',
              description:res.message
            });
            that.loadData();
          } else {
            that.$notification.warning({
              message:'消息',
              description:res.message
            });
          }
        });
      },
      handleStatus(id, status) {
        let _this = this
        putAction(this.url.changeStatus, { id: id, status: status }).then((res) => {
          if (res.success) {
            _this.$notification.success({
              message:'消息',
              description:"操作成功"
            });
            _this.loadData()
          } else {
            _this.$notification.warning({
              message:'消息',
              description:"操作失败"
            });
          }
        })
      },
    },
    created() {
    }
  }
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
</style>
src/views/base/modules/FactoryManager/FactoryEquipment.vue
ÎļþÃû´Ó src/views/system/modules/ProductionManager/ProductionEquipment.vue ÐÞ¸Ä
@@ -72,7 +72,7 @@
  import { getAction,postAction } from '@/api/manage'
  import qs from 'qs'
  export default {
    name: 'ProductionEquipment',
    name: 'FactoryEquipment',
    mixins: [JeecgListMixin],
    data(){
      return {
src/views/base/modules/FactoryManager/FactoryModal.vue
ÎļþÃû´Ó src/views/system/modules/ProductionManager/ProductionModal.vue ÐÞ¸Ä
@@ -16,25 +16,25 @@
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="车间编码"
          prop="productionCode"
          prop="factoryCode"
          :hidden="false"
          hasFeedback >
          <a-input id="productionCode" placeholder="请输入产线/车间编号" v-model="model.productionCode"/>
          <a-input id="factoryCode" placeholder="请输入产线/车间编号" v-model="model.factoryCode"/>
        </a-form-model-item>
        <a-form-model-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="车间名称"
          prop="productionName"
          prop="factoryName"
          :hidden="false"
          hasFeedback >
          <a-input id="departName" placeholder="请输入产线/车间名称" v-model="model.productionName"/>
          <a-input id="factoryName" placeholder="请输入产线/车间名称" v-model="model.factoryName"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" :hidden="seen" label="上级车间" hasFeedback>
          <a-tree-select
            style="width:100%"
            :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
            :treeData="departTree"
            :treeData="factoryTree"
            v-model="model.parentId"
            placeholder="请选择上级车间"
            :disabled="condition">
@@ -44,13 +44,13 @@
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="排序">
          <a-input-number v-model="model.productionOrder"/>
          <a-input-number v-model="model.sorter"/>
        </a-form-model-item>
        <a-form-model-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="备注">
          <a-textarea placeholder="请输入备注" v-model="model.memo"/>
          <a-textarea placeholder="请输入备注" v-model="model.remark"/>
        </a-form-model-item>
      </a-form-model>
@@ -63,22 +63,17 @@
  import { queryById } from '@/api/api'
  import pick from 'lodash.pick'
  export default {
    name: "ProductionModal",
    name: "FactoryModal",
    components: {  },
    data () {
      return {
        departTree:[],
        orgTypeData:[],
        phoneWarning:'',
        departName:"",
        factoryTree:[],
        title:"操作",
        seen:false,
        visible: false,
        condition:true,
        disableSubmit:false,
        model: {},
        menuhidden:false,
        menuusing:true,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
@@ -90,10 +85,10 @@
        confirmLoading: false,
        validatorRules:{
          productionName:[{ required: true, message: '请输入产线/车间名称!' }],
          factoryName:[{ required: true, message: '请输入产线/车间名称!' }],
        },
        url: {
          add: "/mdc/mdcProduction/add",
          add: "/base/factory/add",
        },
        dictDisabled:true,
      }
@@ -105,24 +100,24 @@
        var that = this;
        queryById().then((res)=>{
          if(res.success){
            that.departTree = [];
            that.factoryTree = [];
            for (let i = 0; i < res.result.length; i++) {
              let temp = res.result[i];
              that.departTree.push(temp);
              that.factoryTree.push(temp);
            }
          }
        })
      },
      add (depart) {
        if(depart){
      add (factory) {
        if(factory){
          this.seen = false;
          this.dictDisabled = false;
        }else{
          this.seen = true;
          this.dictDisabled = true;
        }
        this.edit(depart);
        this.edit(factory);
      },
      edit (record) {
        this.visible = true;
src/views/base/modules/group/GroupModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,171 @@
<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
    wrapClassName="ant-modal-cust-warp"
    style="top:5%;height: 85%;overflow-y: hidden">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form"  v-bind="layout"  :model="model" :rules="validatorRules">
        <a-form-model-item label="班组编码" required prop="groupCode">
          <a-input v-model="model.groupCode" :disabled="roleDisabled"  placeholder="请输入班组编码"/>
        </a-form-model-item>
        <a-form-model-item label="班组名称" required prop="groupName">
          <a-input v-model="model.groupName" placeholder="请输入班组名称"/>
        </a-form-model-item>
         <a-form-model-item label="班组长" prop="groupManager">
          <j-dict-select-tag
                type="list"
                v-model="model.groupManager"
                :trigger-change="true"
                dictCode="sys_user,realname,id"
                placeholder="请选择班组长"
              />
        </a-form-model-item>
         <a-form-model-item label="产线" prop="factoryId">
          <j-dict-select-tag
                type="list"
                v-model="model.factoryId"
                :trigger-change="true"
                dictCode="base_factory,factory_name,id"
                placeholder="请选择产线"
              />
        </a-form-model-item>
         <a-form-model-item label="班次" prop="shiftId">
          <j-dict-select-tag
                type="list"
                v-model="model.shiftId"
                :trigger-change="true"
                dictCode="base_shift,shift_name,id"
                placeholder="请选择班次"
              />
        </a-form-model-item>
        <a-form-model-item label="备注" prop="remark">
          <a-textarea :rows="5" v-model="model.remark" placeholder="请输入备注"/>
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>
<script>
  import {duplicateCheck } from '@/api/api'
  import {postAction,requestPut} from '@/api/manage'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'
  export default {
    name: "GroupModal",
    components: {
    JDictSelectTag,
  },
    data () {
      return {
        title:"操作",
        visible: false,
        roleDisabled: false,
        model: {},
        layout: {
          labelCol: { span: 3 },
          wrapperCol: { span: 14 },
        },
        confirmLoading: false,
        validatorRules:{
          groupName: [
            { required: true, message: '请输入班组名称!' },
            { min: 2, max: 30, message: '长度在 2 åˆ° 30 ä¸ªå­—符', trigger: 'blur' }
          ],
          groupCode: [
            { required: true, message: '请输入班组名称!'},
            { min: 0, max: 64, message: '长度不超过 64 ä¸ªå­—符', trigger: 'blur' },
            { validator: this.validategroupCode}
          ],
          remark: [
            { min: 0, max: 126, message: '长度不超过 126 ä¸ªå­—符', trigger: 'blur' }
          ]
        },
        url: {
          add: "/base/shiftGroup/add",
          edit: "/base/shiftGroup/edit",
        }
      }
    },
    created () {
      //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$refs.form.clearValidate();
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // è§¦å‘表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let obj;
            if(!this.model.id){
              obj=postAction(this.url.add, this.model)
            }else{
              obj=requestPut(this.url.edit, this.model, {
                    id: this.model.id
                  })
            }
            obj.then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
            return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },
      validategroupCode(rule, value, callback){
        if(/[\u4E00-\u9FA5]/g.test(value)){
          callback("班组编码不可输入汉字!");
        }else{
          let params = {
            tableName: "base_shift_group",
            fieldName: "group_code",
            fieldVal: value,
            dataId: this.model.id,
          };
          duplicateCheck(params).then((res)=>{
            if(res.success){
              callback();
            }else{
              callback(res.message);
            }
          });
        }
      }
    }
  }
</script>
<style scoped>
</style>
src/views/base/modules/group/SelectUserModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,287 @@
<template>
  <div>
    <a-modal
      centered
      :title="title"
      :width="1000"
      :visible="visible"
      @ok="handleOk"
      @cancel="handleCancel"
      cancelText="关闭">
      <!-- æŸ¥è¯¢åŒºåŸŸ -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline"  @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :span="10">
              <a-form-item label="用户账号">
                <a-input placeholder="请输入用户账号" v-model="queryParam.username"></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="8">
                    <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                      <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                      <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                    </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- table区域-begin -->
      <div>
        <a-table
          size="small"
          bordered
          rowKey="id"
          :columns="columns1"
          :dataSource="dataSource1"
          :pagination="ipagination"
          :loading="loading"
          :scroll="{ y: 240 }"
          :rowSelection="{selectedRowKeys: selectedRowKeys,onSelectAll:onSelectAll,onSelect:onSelect,onChange: onSelectChange}"
          @change="handleTableChange">
        </a-table>
      </div>
      <!-- table区域-end -->
    </a-modal>
  </div>
</template>
<script>
  import {filterObj} from '@/utils/util'
  import {getAction} from '@/api/manage'
  export default {
    name: "SelectUserModal",
    data() {
      return {
        title: "添加班组人员",
        names: [],
        visible: false,
        placement: 'right',
        description: '',
        // æŸ¥è¯¢æ¡ä»¶
        queryParam: {},
        // è¡¨å¤´
        columns1: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 50,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '用户账号',
            align: "center",
            width: 100,
            dataIndex: 'username'
          },
          {
            title: '用户名称',
            align: "center",
            width: 100,
            dataIndex: 'realname'
          },
          {
            title: '性别',
            align: "center",
            width: 100,
            dataIndex: 'sex_dictText'
          },
          {
            title: '电话',
            align: "center",
            width: 100,
            dataIndex: 'phone'
          },
          {
            title: '部门',
            align: "center",
            width: 150,
            dataIndex: 'orgCode'
          }
        ],
        columns2: [
          {
            title: '用户账号',
            align: "center",
            dataIndex: 'username',
          },
          {
            title: '用户名称',
            align: "center",
            dataIndex: 'realname',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            width: 100,
            scopedSlots: {customRender: 'action'},
          }
        ],
        //数据集
        dataSource1: [],
        dataSource2: [],
        // åˆ†é¡µå‚æ•°
        ipagination: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " å…±" + total + "条"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        isorter: {
          column: 'createTime',
          order: 'desc',
        },
        loading: false,
        selectedRowKeys: [],
        selectedRows: [],
        url: {
          list: "/sys/user/list",
        }
      }
    },
    created() {
      this.loadData();
    },
    methods: {
      searchQuery() {
        this.loadData(1);
      },
      searchReset() {
        this.queryParam = {};
        this.loadData(1);
      },
      handleCancel() {
        this.visible = false;
      },
      handleOk() {
        this.dataSource2 = this.selectedRowKeys;
        console.log("data:" + this.dataSource2);
        this.$emit("selectFinished", this.dataSource2);
        this.visible = false;
      },
      add() {
        this.visible = true;
      },
      loadData(arg) {
        //加载数据 è‹¥ä¼ å…¥å‚æ•°1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource1 = res.result.records;
            this.ipagination.total = res.result.total;
          }
        })
      },
      getQueryParams() {
        var param = Object.assign({}, this.queryParam, this.isorter);
        param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        return filterObj(param);
      },
      getQueryField() {
        //TODO å­—段权限控制
      },
      onSelectAll(selected, selectedRows, changeRows) {
        if (selected === true) {
          for (var a = 0; a < changeRows.length; a++) {
            this.dataSource2.push(changeRows[a]);
          }
        } else {
          for (var b = 0; b < changeRows.length; b++) {
            this.dataSource2.splice(this.dataSource2.indexOf(changeRows[b]), 1);
          }
        }
        // console.log(selected, selectedRows, changeRows);
      },
      onSelect(record, selected) {
        if (selected === true) {
          this.dataSource2.push(record);
        } else {
          var index = this.dataSource2.indexOf(record);
          //console.log();
          if (index >= 0) {
            this.dataSource2.splice(this.dataSource2.indexOf(record), 1);
          }
        }
      },
      onSelectChange(selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectedRows;
      },
      onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
      },
      handleDelete: function (record) {
        this.dataSource2.splice(this.dataSource2.indexOf(record), 1);
      },
      handleTableChange(pagination, filters, sorter) {
        //分页、排序、筛选变化时触发
        console.log(sorter);
        //TODO ç­›é€‰
        if (Object.keys(sorter).length > 0) {
          this.isorter.column = sorter.field;
          this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
        }
        this.ipagination = pagination;
        this.loadData();
      }
    }
  }
</script>
<style lang="less" scoped>
  .ant-card-body .table-operator {
    margin-bottom: 18px;
  }
  .ant-table-tbody .ant-table-row td {
    padding-top: 15px;
    padding-bottom: 15px;
  }
  .anty-row-operator button {
    margin: 0 5px
  }
  .ant-btn-danger {
    background-color: #ffffff
  }
  .ant-modal-cust-warp {
    height: 100%
  }
  .ant-modal-cust-warp .ant-modal-body {
    height: calc(100% - 110px) !important;
    overflow-y: auto
  }
  .ant-modal-cust-warp .ant-modal-content {
    height: 90% !important;
    overflow-y: hidden
  }
</style>
src/views/base/modules/shift/ShiftModel.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,324 @@
<template>
  <a-modal :title="title" :width="800" :visible="visible" :confirmLoading="confirmLoading"
           @ok="handleOk" @cancel="handleCancel" cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="班次编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input allow-clear placeholder="请输入班次编码"
                       v-decorator="['shiftCode',validatorRules.shiftCode]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="班次名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input allow-clear placeholder="请输入班次名称" v-decorator="['shiftName',validatorRules.shiftName]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
             <a-time-picker v-decorator="['startTime',validatorRules.startTime]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
             <a-time-picker v-decorator="['endTime',validatorRules.endTime]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="工作时长" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['workHours',validatorRules.workHours]" placeholder="请输入工作时长(小时)" style="width: 100%" />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="是否跨天" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-switch v-model="crossDayFlag" checked-children="是" un-checked-children="否"/>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
  import moment from 'moment'
  import pick from 'lodash.pick'
  import {
    getAction,
    postAction,
    requestPut
  } from '@/api/manage'
  import {
    duplicateCheck
  } from '@/api/api'
  export default {
    name: 'ShiftModel',
    components: {},
    props: {},
    data() {
      return {
        title: '',
        crossDayFlag: false,
        visible: false,
        model: {},
        labelCol: {
          xs: {
            span: 24
          },
          sm: {
            span: 6
          }
        },
        wrapperCol: {
          xs: {
            span: 24
          },
          sm: {
            span: 18
          }
        },
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules: {
          shiftCode: {
            rules: [
              {
                required: true,
                message: '请输入班次编号'
              },
              { validator: this.validateNum }
            ]
          },
          shiftName: {
            rules: [
              {
                required: true,
                message: '请输入班次名称'
              },
              { validator: this.validateName }
            ]
          },
          startDate: {
            rules: [
              {
                required: true,
                message: '请选择开始时间'
              }
            ]
          },
          endDate: {
            rules: [
              {
                required: true,
                message: '请选择结束时间'
              }
            ]
          }
        },
        url: {
          add: '/base/shift/add',
          edit: '/base/shift/edit',
          list: '/base/shift/list'
        },
        disableSubmit: true
      }
    },
    created() {
    },
    methods: {
      add() {
        let _this = this
        this.visible = true
        this.form.resetFields()
        this.model = {}
        this.$nextTick(() => {
          this.crossDayFlag = false
        })
      },
      edit(record) {
        this.form.resetFields()
        this.model = Object.assign({}, record)
        this.visible = true
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model, 'shiftCode', 'shiftName', 'startTime', 'endTime','workHours'))
          this.form.setFieldsValue({
            startTime: moment(this.model.startTime, 'HH:mm:ss'),
            endTime: moment(this.model.endTime, 'HH:mm:ss')
          })
          if (record.crossDayFlag == '1') {
            this.crossDayFlag = true
          } else {
            this.crossDayFlag = false
          }
        })
      },
      close() {
        this.$emit('close')
        this.visible = false
      },
      handleOk() {
        const that = this
        // è§¦å‘表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            // debugger
            that.confirmLoading = true
            let formData = Object.assign(this.model, values)
            if(that.crossDayFlag == true){
              formData.crossDayFlag = '1'
            }else if(that.crossDayFlag == false){
              formData.crossDayFlag = '0'
            }
            formData.startTime = moment(formData.startTime).format('HH:mm:ss')
            formData.endTime = moment(formData.endTime).format('HH:mm:ss')
            if (formData.crossDayFlag == '0') {
               let startTimeOne = formData.startTime.replace(/:/g, '')
              let endTimeOne = formData.endTime.replace(/:/g, '')
              if (startTimeOne > endTimeOne) {
                // that.$message.warning("非跨天班次结束时间不能小于等于开始时间!")
                that.$notification.warning({
                  message: '消息',
                  description: '非跨天班次结束时间不能小于等于开始时间!'
                })
                that.confirmLoading = false
                that.close()
              } else {
                formData.shiftStatus = 1
                let obj
                if (!this.model.id) {
                  obj = postAction(this.url.add, formData)
                } else {
                  obj = requestPut(this.url.edit, formData, {
                    id: this.model.id
                  })
                }
                obj.then((res) => {
                  if (res.success) {
                    // that.$message.success("保存成功")
                    that.$notification.success({
                      message: '消息',
                      description: '保存成功'
                    })
                    that.$emit('ok', res.result)
                  } else {
                    // that.$message.warning(res.message)
                    that.$notification.warning({
                      message: '消息',
                      description: res.message
                    })
                  }
                }).finally(() => {
                  that.confirmLoading = false
                  that.close()
                })
              }
            } else {
              formData.shiftStatus = 1
              let obj
              if (!this.model.id) {
                obj = postAction(this.url.add, formData)
              } else {
                obj = requestPut(this.url.edit, formData, {
                  id: this.model.id
                })
              }
              obj.then((res) => {
                if (res.success) {
                  // that.$message.success
                  that.$notification.success({
                    message: '消息',
                    description: '保存成功'
                  })
                  that.$emit('ok', res.result)
                } else {
                  // that.$message.warning(res.message)
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              }).finally(() => {
                that.confirmLoading = false
                that.close()
              })
            }
          }
        })
      },
      handleCancel() {
        this.close()
      },
      //验证 ç¼–码
      validateNum(rule, value, callback) {
        var params = {
          tableName: 'base_shift',
          fieldName: 'shift_code',
          fieldVal: value,
          dataId: this.model.id,
          //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false å‡åˆ é™¤ï¼štrue
          delFlag: 'true'
        }
        duplicateCheck(params).then((res) => {
          if (res.success) {
            callback()
          } else {
            callback('班次编号已存在!')
          }
        })
      },
      //验证 åç§°
      validateName(rule, value, callback) {
        var params = {
          tableName: 'base_shift',
          fieldName: 'shift_name',
          fieldVal: value,
          dataId: this.model.id,
          //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false å‡åˆ é™¤ï¼štrue
          delFlag: 'true',
        };
        duplicateCheck(params).then((res) => {
          if (res.success) {
            callback();
          } else {
            callback("班次名称已存在!");
          }
        })
      },
    }
  }
</script>
<style scoped>
  .ant-btn {
    padding: 0 10px;
    margin-left: 3px;
  }
  .ant-form-item-control {
    line-height: 0px;
  }
  /** ä¸»è¡¨å•行间距 */
  .ant-form .ant-form-item {
    margin-bottom: 10px;
  }
  /** Tab页面行间距 */
  .ant-tabs-content .ant-form-item {
    margin-bottom: 0px;
  }
</style>
src/views/mdc/base/ShiftManager.vue
ÎļþÒÑɾ³ý