Browse Source

提交

dev
gwbvipvip 9 months ago
parent
commit
4fd3f8966a
7 changed files with 148 additions and 41 deletions
  1. +14
    -7
      src/pages/device/deviceInfo/index.jsx
  2. +1
    -1
      src/pages/device/deviceInfo/services.js
  3. +80
    -2
      src/pages/device/deviceVesion/components/CreateForm.jsx
  4. +16
    -7
      src/pages/device/deviceVesion/index.jsx
  5. +7
    -0
      src/pages/device/deviceVesion/services.js
  6. +1
    -0
      src/pages/goods/goodsInfo/index.jsx
  7. +29
    -24
      src/pages/goods/newgoods/index.jsx

+ 14
- 7
src/pages/device/deviceInfo/index.jsx View File

@@ -323,14 +323,21 @@ const GoodsTypeManage = () => {
key="add"
onClick={ async() => {
const response = await TechnologyTemplateExport(record.id);
const blob = new Blob([response]);
const url = URL.createObjectURL(blob);
console.log(blob, url);
const response = await TechnologyTemplateExport(record.id);
if(response==""){
message.error('当前模板不存在!');
return;
}
// const blob = new Blob([response]);
// const url = URL.createObjectURL(blob);
// console.log(blob, url);
// const link = document.createElement('a');
// link.download = `工艺模板_${new Date(Date.now()).toLocaleString()}.xls`;
// link.href = url;
// link.click();
const link = document.createElement('a');
link.download = `工艺模板_${new Date(Date.now()).toLocaleString()}.xls`;
link.href = url;
link.click();
link.href = response;
link.click();
}}
>
导出工艺模版


+ 1
- 1
src/pages/device/deviceInfo/services.js View File

@@ -204,7 +204,7 @@ export async function GetDeviceVesion(TypeCode) {
export async function TechnologyTemplateExport(data) {
return request(`/kitchen/api/goodes/TechnologyTemplateExport?deviceId=${data}`, {
method: 'post',
responseType: 'blob'
// responseType: 'blob'
});
}



+ 80
- 2
src/pages/device/deviceVesion/components/CreateForm.jsx View File

@@ -1,8 +1,74 @@
import React from 'react';
import { Modal, Form, Input, Button, Select } from 'antd';
import { Modal, Form, Input, Button, Select,Upload} from 'antd';
import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
import { GetCosRequestURL } from '../services';
import axios from 'axios';


const CreateForm = (props) => {
props.form.setFieldsValue(props.values);
const { Option, OptGroup } = Select;
const uploadProp = {
name: 'file',
showUploadList: false,
multiple: false,
accept: '.xlsx, .xls',
// 这里需要指定文件上传的content-type
headers: {
'Content-Type': 'application/octet-stream',
},
customRequest({
action,
file,
headers,
onError,
onProgress,
onSuccess,
withCredentials,
}) {

console.log("上传图片", file);
//覆盖action 上传之前获取上传地址
var index = file.name.lastIndexOf(".");
var ext = file.name.substr(index + 1);

let fileData = null;
GetCosRequestURL({ directory: "goods", fileExtension: ext, method: "PUT" }).then((r) => {
action = r.allUrl;
const reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = (e) => {
//console.log("fdasa","fdsafdsfdsafd");
// 在文件读取结束后执行的操作
fileData = e.target.result;
// 使用 axios 进行文件上传的请求
axios.put(action, fileData, {
withCredentials,
headers,
onUploadProgress: ({ total, loaded }) => {
// 进行上传进度输出,更加直观
onProgress({ percent: Math.round(loaded / total * 100).toFixed(2) }, file);
},
}).then(response => {
console.log('onSuccess', response, file);
if (response.status == 200 || response.statusText == 'OK') {
props.form.setFieldsValue({ templatePath: r.seeUrl });
}
// onSuccess(response, file);
})
.catch(onError);
};
});
return {
abort() {
console.log('upload progress is aborted.');
},
};
},
//defaultFileList: props.location.query.values ? props.location.query.values : null

};

return (
<Modal
title={props.values.id ? '编辑' : '新建'}
@@ -18,7 +84,8 @@ const CreateForm = (props) => {
<Form
layout="vertical"
preserve={false}
initialValues={props.values}
form={props.form}
//initialValues={props.values}
onFinish={props.onFinish} >
<Form.Item name="id" hidden={true}>
<Input />
@@ -37,6 +104,17 @@ const CreateForm = (props) => {
})}
</Select>
</Form.Item>
<Form.Item label={"模板路径"} name="templatePath" >
<Input />
</Form.Item>
<Form.Item name="templatePath1" label="模板"
>
<Upload {...uploadProp} >
{<Button icon={<UploadOutlined />}>上传</Button>}
</Upload>
</Form.Item>


<Form.Item label={'状态'} name="status" rules={[{ required: true }]}>
<Select placeholder="请选择状态">
<OptGroup>


+ 16
- 7
src/pages/device/deviceVesion/index.jsx View File

@@ -1,5 +1,5 @@

import { Modal,Button, message, } from 'antd';
import { Modal,Button, message,Form } from 'antd';
import React, { useState, useRef,useEffect } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons';
@@ -81,6 +81,7 @@ const GoodsTypeManage = () => {
const [DictData, setDictData] = useState([]);
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const [form] = Form.useForm();
const columns = [
{
title: '主键',
@@ -99,6 +100,11 @@ const GoodsTypeManage = () => {
dataIndex: 'deviceTypeKey',
valueType: 'textarea',
},
{
title: '模板地址',
dataIndex: 'templatePath',
valueType: 'textarea',
},
{
title: '操作',
dataIndex: 'option',
@@ -109,13 +115,14 @@ const GoodsTypeManage = () => {
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
// form.setFielsValue(record)
}} > 更新</a>,
<a
key="config"
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
}} > 下载工艺模板</a>
// <a
// key="config"
// onClick={() => {
// handleModalVisible(true);
// setCurrentRow(record);
// }} > 下载工艺模板</a>
],
},
];
@@ -151,6 +158,7 @@ const GoodsTypeManage = () => {
type="primary"
key="primary"
onClick={() => {
// form.setFielsValue(currentRow)
handleModalVisible(true);
}} >
<PlusOutlined /> 新建
@@ -224,6 +232,7 @@ const GoodsTypeManage = () => {
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
form={form}
dicData={DictData}
/>
</PageContainer>


+ 7
- 0
src/pages/device/deviceVesion/services.js View File

@@ -37,4 +37,11 @@ export async function GetDicList(TypeCode) {
return request(`/kitchen/api/dict-data/dic-list/${TypeCode}`, {
method: 'Get',
});
}

export async function GetCosRequestURL(data) {
return request(`/kitchen/api/systemconfig/GetCosRequestSignURL`, {
method: 'POST',
data: data,
});
}

+ 1
- 0
src/pages/goods/goodsInfo/index.jsx View File

@@ -225,6 +225,7 @@ const Advanced = (props) => {
bordered={false}
>
<Form
form={form}
labelCol={{ span: 4 }}
wrapperCol={{ span: 6 }}
layout="horizontal"


+ 29
- 24
src/pages/goods/newgoods/index.jsx View File

@@ -351,7 +351,8 @@ const GoodsManage = () => {
name: 'file',
action: '/kitchen/api/goodes/ExportGood',
headers: {
authorization: 'authorization-text',
// authorization: 'authorization-text',
Authorization:'Bearer ' + localStorage.getItem('token')
},
onChange(info) {
if (info.file.status !== 'uploading') {
@@ -394,34 +395,38 @@ const GoodsManage = () => {
<Button
key="primary"
onClick={async () => {
const response = await GoodsTemplateExport();
const blob = new Blob([response]);
const url = URL.createObjectURL(blob);
console.log(blob, url);
// const response = await GoodsTemplateExport();
// const blob = new Blob([response]);
// const url = URL.createObjectURL(blob);
// console.log(blob, url);
// const link = document.createElement('a');
// link.download = `商品导入模板_${new Date(Date.now()).toLocaleString()}.xls`;
// link.href = url;
// link.click();
const link = document.createElement('a');
link.download = `商品导入模板_${new Date(Date.now()).toLocaleString()}.xls`;
link.href = url;
link.click();
link.href = "https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com//Franchisee/gzaxn@163.com/goods/133458056374859886.xlsx";
link.click();
}}
>
<UploadOutlined /> 下载商品导入模板
</Button>,
<Popconfirm
type="primary"
key="primary"
title="导入后重复数据将被替换"
okText="是"
cancelText="否"
onConfirm={() => {
handleRemove([record.id]);
actionRef.current?.reloadAndRest();
}}
onCancel={() => {}}
>
<Upload {...props}>
<Button icon={<UploadOutlined />}>导入商品</Button>
</Upload>
</Popconfirm>
// <Popconfirm
// type="primary"
// key="primary"
// title="导入后重复数据将被替换"
// okText="是"
// cancelText="否"
// onConfirm={() => {
// handleRemove([record.id]);
// actionRef.current?.reloadAndRest();
// }}
// onCancel={() => {}}
// >
// </Popconfirm>
<Upload {...props}>
<Button icon={<UploadOutlined />}>导入商品</Button>
</Upload>
]}


Loading…
Cancel
Save