Cloud Zhang
2024-05-16 f4c05057fb284287997775f373c33f73228a02c3
工具保养项目
已修改1个文件
已添加4个文件
889 ■■■■■ 文件已修改
src/api/tigerapi/mes/smt/smtmtproject.ts 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/mes/smt/tool/smt_mt_project/ProjectDrawer.vue 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/mes/smt/tool/smt_mt_project/smt_mt_project.data.ts 433 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/mes/smt/tool/smt_tool/smt_tool.data.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/tigerapi/mes/smt/smtmtproject.ts
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,190 @@
import { buildUUID } from '../../../../utils/uuid';
//import { ApiAction, ApiActionPage } from '../../model/baseModel';
import { genAction, Api } from '../../system';
import { useUserStore } from '/@/store/modules/user';
import { defHttp } from '/@/utils/http/axios';
import { isNullOrEmpty } from '/@/utils/is';
import { formatToDateTime } from '/@/utils/dateUtil';
/*
 * èŽ·å–å·¥å…·ä¿å…»é¡¹ç›®
 */
export const getListByPage = async (params: any) => {
  let order = ''
  if (params.order != undefined) {
    order = params.order == 'descend' ? (params.field + ' desc') : params.field
  }
  let sqlcmd = '1=1';
  if (params?.FEEDER_CODE != undefined && params?.FEEDER_CODE != '') {
    sqlcmd += " And FEEDER_CODE like '%" + params?.FEEDER_CODE + "%'";
  }
  let option = {
    UserId: useUserStore().getUserInfo.userId as string,
    ByOrg: true,
    OrgCode: useUserStore().getUserInfo.orgCode as string
  }
  if (!isNullOrEmpty(params.page)) {
    const usParams = genAction('SMT_MT_PROJECT', {
      QueryAble_T: '',
      where: sqlcmd,
      order: order,
      page: {
        pageAble_T: 'string',
        draw: 1,
        pageIndex: params.page,
        pageSize: params.pageSize,
      }
    });
    return getListByPageAsync(usParams);
  } else {
    const usParams = genAction('SMT_MT_PROJECT', {
      QueryAble_T: '',
      where: sqlcmd
    });
    return getListByPageAsync(usParams);
  }
  // const rParams = genActionPage('BIZ_ERP_PROD_IN', sqlcmd, params.page, params.pageSize,option);
  // return getFinishedwarehouseListByPageAsync(rParams);
};
async function getListByPageAsync(params: any) {
  const data = await defHttp.post(
    { url: Api.QueryUrl, params },
    {
      isTransformResponse: false,
    },
  );
  let model = {}
  if (isNullOrEmpty(data.Data.page)) {
    model = {
      items: data.Data.Items,
    };
  } else {
    model = {
      items: data.Data.page.data,
      total: data.Data.page.totals,
    };
  }
  return model;
}
//新增飞达信息
export const Save = async (params: Recordable, isUpdate: boolean, isbaofei: boolean) => {
  const item: any = {
    ID: params.ID,
    CREATE_TIME: params?.CREATE_TIME,
    CREATE_USER: params?.CREATE_USER,
    UPDATE_TIME: params?.UPDATE_TIME,
    UPDATE_USER: params?.UPDATE_USER,
    GHOST_ROW: params?.GHOST_ROW,
    AUTH_ORG: params?.AUTH_ORG,
    AUTH_PROD: params?.AUTH_PROD,
    AUTH_WH: params?.AUTH_WH,
    PROJ_CODE: params?.PROJ_CODE,
    PROJ_NAME: params?.PROJ_NAME,
    TOOL_TYPE: params?.TOOL_TYPE,
    ITEM01: params?.ITEM01,
    ITEM02: params?.ITEM02,
    ITEM03: params?.ITEM03,
    ITEM04: params?.ITEM04,
    ITEM05: params?.ITEM05,
    ITEM06: params?.ITEM06,
    ITEM07: params?.ITEM07,
    ITEM08: params?.ITEM08,
    ITEM09: params?.ITEM09,
    ITEM10: params?.ITEM10,
    ITEM11: params?.ITEM11,
    ITEM12: params?.ITEM12,
    ITEM13: params?.ITEM13,
    ITEM14: params?.ITEM14,
    ITEM15: params?.ITEM15,
    ITEM16: params?.ITEM16,
    ITEM17: params?.ITEM17,
    ITEM18: params?.ITEM18,
    ITEM19: params?.ITEM19,
    ITEM20: params?.ITEM20,
    REMARK: params?.REMARK,
  };
  let data;
  if (isUpdate) {
    if (isbaofei) {
      item.STATUS = 5;
    }
    const time = new Date();
    item.UPDATE_TIME = formatToDateTime(time);
    item.UPDATE_USER = useUserStore().getUserInfo.userId as string;
    // regionitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
    // regionitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
    data = await defHttp.post(
      { url: Api.UpdateEntity, params: genAction('SMT_MT_PROJECT', item) },
      {
        errorMessageMode: 'none',
        isTransformResponse: false,
      },
    );
  } else {
    // const usParams = genAction(
    //   'SMT_SOLDER',
    //   "REGION_CODE='" + params.REGION_CODE + "'AND AUTH_ORG='" + regionitem.ORG_CODE + "'",
    // );
    //var check = await isExist(usParams);
    //console.log('check',check)
    //if (!check.Data) {
    item.ID = buildUUID(); //生成GUID
    item.UPDATE_TIME = formatToDateTime(new Date());
    item.CREATE_USER = useUserStore().getUserInfo.userId as string;
    item.UPDATE_USER = useUserStore().getUserInfo.userId as string;
    // regionitem.ORG_CODE = useUserStore().getUserInfo.orgCode as string;
    // regionitem.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
    data = await defHttp.post(
      { url: Api.AddEntity, params: genAction('SMT_MT_PROJECT', item) },
      {
        errorMessageMode: 'none',
        isTransformResponse: false,
      },
    );
    //} else {
    // return check.Message;
    //return '重复了';
    //}
  }
  return data;
};
//删除
export const Delete = async (Tool_Id: string) => {
  const usParams = genAction('SMT_MT_PROJECT', `ID='${Tool_Id}'`)
  return await defHttp.post(
    { url: Api.DeleteWhere, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false
    }
  )
}
//下拉列表
// STATUSs å•据状态
export const optionsListApi = async (params: Recordable) => {
  const usParams = genAction('V_SMT_TOOL+ALARM_TYPEs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};
//类型
export const optionsListApiType = async (params: Recordable) => {
  const usParams = genAction('V_SMT_TOOL+TYPEs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};
src/views/tigerprojects/mes/smt/tool/smt_mt_project/ProjectDrawer.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
<template>
  <BasicDrawer
    v-bind="$attrs"
    @register="registerDrawer"
    showFooter
    :title="getTitle"
    width="800px"
    @ok="handleSubmit"
  >
    <BasicForm @register="registerForm" />
  </BasicDrawer>
</template>
<script lang="ts">
  import { defineComponent, ref, computed, unref } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { formSchema } from './smt_mt_project.data';
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { Save } from '/@/api/tigerapi/mes/smt/smtmtproject';
  export default defineComponent({
    name: 'ToolDrawer',
    components: { BasicDrawer, BasicForm },
    emits: ['success', 'register'],
    setup(_, { emit }) {
      const isUpdate = ref(true);
      const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
        resetFields();
        setDrawerProps({ confirmLoading: false });
        isUpdate.value = !!data?.isUpdate;
        if (unref(isUpdate)) {
          setFieldsValue({
            ...data.record,
          });
        }
      });
      const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
        labelWidth: 120,
        schemas: formSchema,
        actionColOptions: {
          span: 24,
        },
        showActionButtonGroup: false,
      });
      const getTitle = computed(() => (!unref(isUpdate) ? '新增工具保养项目' : '编辑工具保养项目'));
      async function handleSubmit() {
        try {
          const values = await validate();
          setDrawerProps({ confirmLoading: true });
          // TODO custom api
          //保存物料
          const apiAction = Save(values, unref(isUpdate),false);
          apiAction.then((action) => {
            if (action.IsSuccessed) {
              closeDrawer();
              emit('success');
            }
          });
        } finally {
          setDrawerProps({ confirmLoading: false });
        }
      }
      return {
        registerDrawer,
        registerForm,
        getTitle,
        handleSubmit,
      };
    },
  });
</script>
src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,190 @@
<template>
  <div>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button color="primary" @click="handleAdd"> æ·»åŠ  </a-button>
        <a-button ghost color="primary" @click="aoaToExcel"> å¯¼å‡º </a-button>
      </template>
      <template #action="{ record }">
        <TableAction :actions="[
      {
        icon: 'clarity:note-edit-line',
        tooltip: '修改',
        onClick: handleEdit.bind(null, record),
      },
      {
        icon: 'ant-design:delete-outlined',
        tooltip: '删除',
        popConfirm: {
          title: '是否确认删除?',
          placement: 'left',
          confirm: handleDelete.bind(null, record),
        },
      },
    ]" />
      </template>
    </BasicTable>
    <Loading :loading="compState.loading" :tip="compState.tip" />
    <!-- <WmsItemDrawer @register="registerDrawer" @success="handleSuccess" /> -->
    <ProjectDrawer @register="registerDrawer" @success="handleSuccess" />
  </div>
</template>
<script lang="ts" setup>
import { reactive, unref } from 'vue';
import { aoaToSheetXlsx } from '/@/components/Excel';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import ProjectDrawer from './ProjectDrawer.vue';
import { useDrawer } from '/@/components/Drawer';
import { columns, searchFormSchema } from './smt_mt_project.data';
import { getListByPage, Save, Delete } from '/@/api/tigerapi/mes/smt/smtmtproject';
import { useGo } from '/@/hooks/web/usePage';
import { Loading } from '/@/components/Loading';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
const { createMessage } = useMessage();
const [registerDrawer, { openDrawer }] = useDrawer();
const go = useGo();
const compState = reactive({
  absolute: false,
  loading: false,
  tip: '加载中...',
});
const [registerTable, { getForm, getPaginationRef, reload }] = useTable({
  title: '工具保养项目',
  api: getListByPage,
  columns,
  formConfig: {
    labelWidth: 120,
    schemas: searchFormSchema,
  },
  actionColumn: {
    width: 120,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: 'right', //undefined,
  },
  ellipsis: true,
  useSearchForm: true,
  showTableSetting: false,
  bordered: true,
  showIndexColumn: false,
});
let arr: any[] = [];
//导出
function aoaToExcel() {
  const totals = getPaginationRef().total
  if (totals < 30000) {
    arr = [];
    compState.loading = true;
    const col = getForm().getFieldsValue()
    getListByPage(col).then((res) => {
      res.items.forEach(element => {
        var TYPE = ''
        switch (element.TOOL_TYPE) {
          case 0:
            TYPE = '钢网';
            break;
          case 1:
            TYPE = '刮刀';
            break;
          default:
            break;
        }
        arr.push({
          '保养项目编码': element.PROJ_CODE,
          '保养项目名称': element.PROJ_NAME,
          '类型': TYPE,
          '保养项1': element.ITEM01,
          '保养项2': element.ITEM02,
          '保养项3': element.ITEM03,
          '保养项4': element.ITEM04,
          '保养项5': element.ITEM05,
          '保养项6': element.ITEM06,
          '保养项7': element.ITEM07,
          '保养项8': element.ITEM08,
          '保养项9': element.ITEM09,
          '保养项10': element.ITEM10,
          '保养项11': element.ITEM11,
          '保养项12': element.ITEM12,
          '保养项13': element.ITEM13,
          '保养项14': element.ITEM14,
          '保养项15': element.ITEM15,
          '保养项16': element.ITEM16,
          '保养项17': element.ITEM17,
          '保养项18': element.ITEM18,
          '保养项19': element.ITEM19,
          '保养项20': element.ITEM20,
          '备注': element.REMARK,
          '创建人': element.CREATE_USER,
          '创建时间': element.CREATE_TIME,
        });
      });
      const arrHeader = columns.map((column) => column.title);
      const arrData = arr.map((item) => {
        return Object.keys(item).map((key) => item[key]);
      });
      // ä¿è¯data顺序与header一致
      if (arr.length < 30000) {
        aoaToSheetXlsx({
          data: arrData,
          header: arrHeader,
          filename: '工具保养项目.xlsx',
        });
      } else {
        createMessage.error(t('导出数据不能超过三万条,如需要更多的请联系管理员'));
      }
      compState.loading = false;
    })
  } else {
    createMessage.error(t('导出数据不能超过三万条,如需要更多的请联系管理员'));
  }
}
//添加
function handleAdd() {
  openDrawer(true, {
    isUpdate: false,
  });
}
//编辑
function handleEdit(record: any) {
  openDrawer(true, {
    isUpdate: true,
    record
  });
}
function handleSuccess() {
  reload();
}
//报废
function handleBao(record: any) {
  const apiAction = Save(record, unref(true), true);
  apiAction.then((action) => {
    if (action.IsSuccessed) {
      createMessage.success(t('已报废'));
      reload();
    } else {
      createMessage.success(t('报废操作失败'));
    }
  });
}
//删除
function handleDelete(record: any) {
  const apiAction = Delete(record.ID);
  apiAction.then((action) => {
    if (action.IsSuccessed) {
      createMessage.success(t('已删除'));
      reload();
    } else {
      createMessage.success(t('删除操作失败'));
    }
  });
}
</script>
src/views/tigerprojects/mes/smt/tool/smt_mt_project/smt_mt_project.data.ts
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,433 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { optionsListApi,optionsListApiType } from '/@/api/tigerapi/mes/smt/smtmtproject';
import { h,unref } from 'vue';
import { Tag ,Tooltip} from 'ant-design-vue';
import{ useLocale } from '/@/locales/useLocale';
const { getLocale }=useLocale();
export const columns: BasicColumn[] = [
  {
    title: '保养项目编码',
    dataIndex: 'PROJ_CODE',
    width:200,
    sorter: true,
    resizable:true
  },
  {
    title: '保养项目名称',
    dataIndex: 'PROJ_NAME',
    width: 100,
    sorter: true,
    resizable:true
  },
  {
    title: '类型',
    dataIndex: 'TOOL_TYPE',
    width: 100,
    sorter: true,
    resizable: true,
    customRender: ({ record }) => {
      const status = record.TOOL_TYPE;
      var text = '';
      var color = '';
      switch (status) {
        case 0:
          text = '钢网';
          color = 'green';
          break;
        case 1:
          text = '刮刀';
          color = 'blue';
          break;
        default:
          break;
      }
      return h(Tooltip, { title: 'xxxxxx' }, () => h(Tag, { color: color }, () => text));
    },
  },
  {
    title: '保养项1',
    dataIndex: 'ITEM01',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项1',
    dataIndex: 'ITEM01',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项2',
    dataIndex: 'ITEM02',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项3',
    dataIndex: 'ITEM03',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项4',
    dataIndex: 'ITEM04',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项5',
    dataIndex: 'ITEM05',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项6',
    dataIndex: 'ITEM06',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项7',
    dataIndex: 'ITEM07',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项8',
    dataIndex: 'ITEM08',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项9',
    dataIndex: 'ITEM09',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项10',
    dataIndex: 'ITEM10',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项11',
    dataIndex: 'ITEM11',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项12',
    dataIndex: 'ITEM12',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项13',
    dataIndex: 'ITEM13',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项14',
    dataIndex: 'ITEM14',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项15',
    dataIndex: 'ITEM15',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项16',
    dataIndex: 'ITEM16',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项17',
    dataIndex: 'ITEM17',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项18',
    dataIndex: 'ITEM18',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项19',
    dataIndex: 'ITEM19',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '保养项20',
    dataIndex: 'ITEM20',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '备注',
    dataIndex: 'REMARK',
    width:100,
    sorter: true,
    resizable:true
  }
  ,
  {
    title: '创建人',
    dataIndex: 'CREATE_USER',
    width:100,
    sorter: true,
    resizable:true
  },
  {
    title: '创建时间',
    dataIndex: 'CREATE_TIME',
    width:100,
    sorter: true,
    resizable:true
  }
];
export const searchFormSchema: FormSchema[] = [
  {
    field: 'PROJ_CODE',
    label: '保养项目编码',
    component: 'Input',
    colProps: { span: 8 },
  }
];
//新增组件export const
export const formSchema: FormSchema[] = [
  {
    label: '保养项目编码',
    field: 'PROJ_CODE',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    field: 'ID',
    label: 'ID',
    component: 'Input',
    show: false,
  },
  {
    label: '保养项目名称',
    field: 'PROJ_NAME',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '类型',
    field: 'TOOL_TYPE',
    required: true,
    component: 'ApiSelect',
    colProps: { span: 8 },
    componentProps: {
      api: optionsListApiType,
      resultField: 'Data',
      labelField: unref(getLocale)=='zh_CN'?'Desc':'Name',
      valueField: 'Value',
    },
  },
  {
    label: '保养项1',
    field: 'ITEM01',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项2',
    field: 'ITEM02',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项3',
    field: 'ITEM03',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项4',
    field: 'ITEM04',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项5',
    field: 'ITEM05',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项6',
    field: 'ITEM06',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项7',
    field: 'ITEM07',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项8',
    field: 'ITEM08',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项9',
    field: 'ITEM09',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项10',
    field: 'ITEM10',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项11',
    field: 'ITEM11',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项12',
    field: 'ITEM12',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项13',
    field: 'ITEM13',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项14',
    field: 'ITEM14',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项15',
    field: 'ITEM15',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项16',
    field: 'ITEM16',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项17',
    field: 'ITEM17',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项18',
    field: 'ITEM18',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项19',
    field: 'ITEM19',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '保养项20',
    field: 'ITEM20',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  },
  {
    label: '备注',
    field: 'REMARK',
    required: true,
    colProps: { span: 8 },
    component: 'Input',
  }
];
src/views/tigerprojects/mes/smt/tool/smt_tool/smt_tool.data.ts
@@ -281,5 +281,5 @@
    required: true,
    component: 'Input',
    colProps: { span: 8 },
  },
  }
];