618 lines
19 KiB
Vue
618 lines
19 KiB
Vue
<template>
|
|
<div class="app-container-content">
|
|
<!-- 寻源需求 -->
|
|
<el-form
|
|
:model="queryParams"
|
|
ref="queryFormRef"
|
|
:inline="true"
|
|
size="default"
|
|
label-width="0"
|
|
>
|
|
<!-- 表单搜索 -->
|
|
<el-row>
|
|
<el-col :span="6">
|
|
<el-form-item prop="maName">
|
|
<el-input
|
|
v-model.trim="queryParams.maName"
|
|
style="width: 100%"
|
|
clearable
|
|
placeholder="请输入自有装备名称"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item prop="maModel">
|
|
<el-input
|
|
v-model.trim="queryParams.maModel"
|
|
style="width: 100%"
|
|
clearable
|
|
placeholder="请输入自有装备规格"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item>
|
|
<el-button class="primary-lease" type="primary" @click="getContractListData"
|
|
>查询</el-button
|
|
>
|
|
<el-button class="primary-lease" type="primary" @click="onReset"
|
|
>重置</el-button
|
|
>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="18">
|
|
<el-form-item>
|
|
<el-button class="primary-lease" type="primary" @click="addContract">新增装备</el-button>
|
|
<el-col :span="3" :offset="1">
|
|
<el-upload
|
|
class="primary-lease"
|
|
:action="uploadUrl"
|
|
:headers="headerInfo"
|
|
:show-file-list="false"
|
|
accept=".xlsx"
|
|
:on-success="handleUpload"
|
|
name="file"
|
|
>
|
|
<el-button type="primary">批量装备上传</el-button>
|
|
</el-upload>
|
|
</el-col>
|
|
<a :href="uploadUrlTemp" download="装备模板下载">
|
|
<el-button
|
|
class="primary-lease"
|
|
type="primary"
|
|
style="margin-left: 20px"
|
|
>装备模板下载</el-button
|
|
>
|
|
</a>
|
|
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
|
|
<!-- 表格 -->
|
|
<el-table
|
|
:data="qualityLis"
|
|
show-overflow-tooltip
|
|
:header-cell-style="{
|
|
background: '#00a288',
|
|
color: '#fff',
|
|
}"
|
|
>
|
|
<!-- <el-table-column align="center" label="装备分类">
|
|
<template #default="{ row }">
|
|
<a style="color: blue">
|
|
{{ row.maType }}
|
|
</a>
|
|
</template>
|
|
</el-table-column> -->
|
|
<el-table-column align="center" prop="maName" label="装备名称" />
|
|
|
|
<el-table-column align="center" prop="maModel" label="装备规格">
|
|
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="maNum" label="装备数量">
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column align="center" label="操作" :width="220">
|
|
<template #default="{ row }">
|
|
<el-button size="small" type="primary" @click="onContract(row, false)">
|
|
编辑
|
|
</el-button>
|
|
<el-button
|
|
size="small"
|
|
type="danger"
|
|
@click="onDelete(row.id, true)"
|
|
|
|
>
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<PagingComponent
|
|
@getList="getContractListData"
|
|
:pageSize="queryParams.pageSize"
|
|
:pageNumber="queryParams.pageNum"
|
|
:total="total"
|
|
/>
|
|
|
|
<!-- 新增和修改弹框 -->
|
|
<!-- 装备新增和修改弹框 -->
|
|
<el-dialog
|
|
v-model="dialogVisibleSettlein"
|
|
:title="settleinTitle"
|
|
width="40%"
|
|
destroy-on-close
|
|
class="centered-dialog"
|
|
:close-on-click-modal="false"
|
|
@close="onDialogClose"
|
|
>
|
|
<el-form
|
|
label-width="140px"
|
|
ref="addAndEditFormRef"
|
|
label-position="right"
|
|
:model="addAndEditForm"
|
|
:rules="addAndEditFormRules"
|
|
>
|
|
<el-row :gutter="20">
|
|
<el-col :span="24">
|
|
<el-form-item label="装备名称:" prop="maName">
|
|
<el-input
|
|
v-model="addAndEditForm.maName"
|
|
maxlength="30"
|
|
placeholder="请输入装备名称"
|
|
clearable
|
|
style="width: 100%"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<!-- <el-row :gutter="20">
|
|
<el-col :span="24">
|
|
<el-form-item label="装备分类:" prop="maType">
|
|
<el-input
|
|
v-model="addAndEditForm.maType"
|
|
maxlength="30"
|
|
placeholder="请输入装备分类"
|
|
clearable
|
|
style="width: 100%"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row> -->
|
|
|
|
<el-row :gutter="20">
|
|
<el-col :span="24">
|
|
<el-form-item label="规格型号:" prop="maModel">
|
|
<el-input
|
|
v-model="addAndEditForm.maModel"
|
|
maxlength="50"
|
|
placeholder="请输入规格型号"
|
|
clearable
|
|
style="width: 100%"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-row :gutter="20">
|
|
<el-col :span="24">
|
|
<el-form-item label="装备数量:" prop="maNum">
|
|
<el-input-number
|
|
v-model="addAndEditForm.maNum"
|
|
:min="1"
|
|
placeholder="请输入数量"
|
|
style="width: 100%"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<!-- <el-row :gutter="20">
|
|
<el-col :span="24">
|
|
<el-form-item label="类型:" prop="type">
|
|
<el-select v-model="addAndEditForm.type" placeholder="请选择类型" style="width: 100%">
|
|
<el-option label="租赁" value="1" />
|
|
<el-option label="自有" value="2" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row> -->
|
|
</el-form>
|
|
|
|
<template #footer>
|
|
<div class="dialog-footer">
|
|
<el-button type="primary" class="primary-lease" @click="onCancel">取消</el-button>
|
|
<el-button class="primary-lease" type="primary" @click="onSubmit()">提交</el-button>
|
|
</div>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import EditorModel from 'components/EditorModel/index.vue'
|
|
|
|
import TableComponent from 'components/TableComponent/index.vue'
|
|
import FormComponent from 'components/FormComponent/index.vue'
|
|
import PagingComponent from 'components/PagingComponent/index.vue'
|
|
import UploadComponentNewTwo from 'components/uploadComponentNewTwo/index.vue'
|
|
import TitleTip from 'components/TitleTip/index.vue'
|
|
import uploadComponent from 'components/uploadComponent/index.vue'
|
|
import previewImg from './previewImg/index.vue'
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import type { FormInstance } from 'element-plus'
|
|
import { ref } from 'vue'
|
|
import { useStore } from 'store/user'
|
|
const store = useStore()
|
|
import { mainStore } from 'store/main'
|
|
// 引入富文本组件
|
|
import { QuillEditor } from '@vueup/vue-quill'
|
|
import 'quill/dist/quill.core.css'
|
|
import 'quill/dist/quill.snow.css'
|
|
import 'quill/dist/quill.bubble.css'
|
|
const uploadUrlTemp = ref('')
|
|
const store2 = mainStore()
|
|
const isViewForm = ref(false)
|
|
|
|
const isDisabled = ref(false)
|
|
|
|
const qualityLis = ref<any>([])
|
|
const queryFormRef = ref<any>(null)
|
|
const batchAddData: any = ref([]) // 批量新增
|
|
const modelValue = ref<any>('')
|
|
const uploadUrl = import.meta.env.VITE_API_URL + '/material-mall/owner/importData?type='+1
|
|
const headerInfo = reactive({
|
|
Authorization: 'Bearer ' + store2.token,
|
|
})
|
|
const handleUpload = (file: any, fileList: any) => {
|
|
console.log('🚀 ~ handleUpload ~ file:', file)
|
|
console.log('🚀 ~ handleUpload ~ fileList:', fileList)
|
|
if (file.code == 200) {
|
|
batchAddData.value = file.data
|
|
} else {
|
|
ElMessage({
|
|
message: file.msg,
|
|
type: 'error',
|
|
})
|
|
}
|
|
getContractListData()
|
|
}
|
|
import {
|
|
getContractListApi, //列表
|
|
addContractApi, //新增
|
|
editContractApi, //修改
|
|
delContractApi, //删除
|
|
updateStatus, //修改状态
|
|
getContractSelectList, //自有装备选择列表
|
|
} from 'http/api/owner-manage'
|
|
import { InfoFilled, UploadFilled } from '@element-plus/icons-vue'
|
|
const total = ref(0)
|
|
const createTime = ref([])
|
|
/* 查询参数 */
|
|
const queryParams: any = reactive({
|
|
maName: '',
|
|
maModel: '',
|
|
type:'1',
|
|
pageSize: 10,
|
|
pageNum: 1,
|
|
})
|
|
const addAndEditForm = ref<any>({
|
|
id: null,
|
|
maName: '',
|
|
maType: '',
|
|
maModel: '',
|
|
maNum: '',
|
|
type: '1'
|
|
})
|
|
|
|
// 获取列表
|
|
const getContractListData = async () => {
|
|
const { data: res }: any = await getContractListApi(queryParams)
|
|
qualityLis.value = res.rows
|
|
total.value = res.total
|
|
}
|
|
|
|
// 重置
|
|
const onReset = () => {
|
|
createTime.value = []
|
|
queryParams.startTime = ''
|
|
queryParams.endTime = ''
|
|
queryParams.pageNum = 1
|
|
queryParams.pageSize = 10
|
|
queryFormRef.value.resetFields()
|
|
getContractListData()
|
|
}
|
|
|
|
//状态选择
|
|
const handleStatusChange = async (row: any) => {
|
|
console.log('111111', row)
|
|
const id = row.id
|
|
const res: any = await updateStatus({ id, status: row.status })
|
|
if (res.code === 200) {
|
|
ElMessage({
|
|
type: 'success',
|
|
message: '状态修改成功',
|
|
})
|
|
await getContractListData()
|
|
}
|
|
}
|
|
|
|
const addAndEditFormRef = ref()
|
|
const settleinTitle = ref('')
|
|
// 自有装备新增弹框显示隐藏
|
|
const dialogVisibleplSettlein: any = ref(false)
|
|
const dialogVisibleSettlein: any = ref(false)
|
|
const dialogVisibleSettleinEdit: any = ref(false)
|
|
const contractList: any = ref([])
|
|
|
|
// 自有装备新增
|
|
const addContract = () => {
|
|
settleinTitle.value = '自有装备新建'
|
|
dialogVisibleSettlein.value = true
|
|
}
|
|
|
|
const handleSelectChange = (selectedId: number) => {
|
|
console.log('111111', selectedId)
|
|
let selectedContract = ''
|
|
contractList.value.forEach((item: any) => {
|
|
if (item.id === selectedId) {
|
|
selectedContract = item.content
|
|
}
|
|
})
|
|
console.log('2222', selectedContract)
|
|
addAndEditForm.value.content = selectedContract
|
|
}
|
|
// 自有装备编辑
|
|
const onContract = (row: any) => {
|
|
addAndEditForm.value.id = row.id
|
|
addAndEditForm.value.maName = row.maName
|
|
addAndEditForm.value.maType = row.maType
|
|
addAndEditForm.value.maModel = row.maModel
|
|
addAndEditForm.value.maNum = row.maNum
|
|
settleinTitle.value = '自有装备修改'
|
|
dialogVisibleSettlein.value = true
|
|
}
|
|
|
|
const onDialogClose = () => {
|
|
addAndEditFormRef.value.resetFields()
|
|
addAndEditForm.value.fileInfoTempList = []
|
|
addAndEditForm.value.fileInfoList = []
|
|
addAndEditForm.value.bmFileInfoList = []
|
|
addAndEditForm.value.id = ''
|
|
addAndEditForm.value.maName = ''
|
|
addAndEditForm.value.maModel = ''
|
|
addAndEditForm.value.maNum = ''
|
|
}
|
|
|
|
const onDialogClose_2 = () => {}
|
|
|
|
// 自定义事件
|
|
const onFileChange = (fileList: any) => {
|
|
addAndEditForm.value.fileInfoTempList = []
|
|
const origin = window.location.origin
|
|
console.log('获取orgin数据', origin)
|
|
const isProd = origin.indexOf('sgwpdm.ah.sgcc.com.cn') > -1
|
|
console.log('获取isProd数据', isProd)
|
|
const fileListTemp = fileList.map((e: any) => {
|
|
console.log('111111', e)
|
|
let testUrl = ''
|
|
console.log('输出env.VITE_API_URL', import.meta.env.VITE_API_URL)
|
|
if (import.meta.env.VITE_API_URL == '/proxyApi') {
|
|
console.log('走入公司测试环境----------')
|
|
testUrl = e.url // 公司-测试环境
|
|
} else {
|
|
console.log('走入宏源测试环境----------')
|
|
testUrl = 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + e.url // 宏源-测试环境
|
|
console.log('输出testUrl----------', testUrl)
|
|
}
|
|
return {
|
|
fileName: e.name,
|
|
fileUrl: testUrl,
|
|
}
|
|
})
|
|
console.log('22222222查看file路径', fileListTemp)
|
|
addAndEditForm.value.fileInfoTempList.push(...fileListTemp)
|
|
}
|
|
|
|
const addAndEditFormRules = reactive({
|
|
maName: [{ required: true, message: '请输入装备名称', trigger: 'blur' }],
|
|
maType: [{ required: true, message: '请输入装备分类', trigger: 'blur' }],
|
|
maModel: [{ required: true, message: '请输入规格型号', trigger: 'blur' }],
|
|
maNum: [{ required: true, type: 'number', message: '请输入装备数量', trigger: 'blur' }]
|
|
})
|
|
|
|
//自有装备模板下载
|
|
const onDownload = async (row) => {
|
|
try {
|
|
const response = await axios.get(row.fileUrl, {
|
|
responseType: 'blob',
|
|
})
|
|
|
|
const url = window.URL.createObjectURL(new Blob([response.data]))
|
|
const link = document.createElement('a')
|
|
link.href = url
|
|
link.setAttribute('download', row.fileName)
|
|
document.body.appendChild(link)
|
|
link.click()
|
|
} catch (error) {
|
|
ElMessage.error('下载失败,请稍后重试')
|
|
}
|
|
}
|
|
const onSubmit = () => {
|
|
addAndEditForm.value.fileInfoList = addAndEditForm.value.fileInfoTempList
|
|
addAndEditFormRef.value.validate(async (valid: any) => {
|
|
if (valid) {
|
|
const SEN_API = settleinTitle.value === '自有装备修改' ? editContractApi : addContractApi
|
|
addAndEditForm.value.bmFileInfoList = addAndEditForm.value.fileInfoList
|
|
const res: any = await SEN_API(addAndEditForm.value)
|
|
if (res.code === 200) {
|
|
ElMessage({
|
|
type: 'success',
|
|
message: '提交成功',
|
|
})
|
|
dialogVisibleSettlein.value = false
|
|
getContractListData();
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
// 删除
|
|
const onDelete = async (id: any) => {
|
|
ElMessageBox.confirm('是否确定删除?', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
})
|
|
.then(() => {
|
|
return delContractApi({ id })
|
|
})
|
|
.then((res) => {
|
|
if (res.code === 200) {
|
|
ElMessage({
|
|
type: 'success',
|
|
message: '删除成功',
|
|
})
|
|
getContractListData();
|
|
}
|
|
})
|
|
.catch(() => {})
|
|
}
|
|
|
|
// 取消按钮
|
|
const onCancel = () => {
|
|
dialogVisibleSettlein.value = false
|
|
}
|
|
|
|
const myQuillEditor = ref()
|
|
|
|
// 样式部分
|
|
const toolbarStyle = {
|
|
width: '100%', // 与编辑工具器一样的宽度
|
|
height: '50px', // 固定高度
|
|
}
|
|
|
|
// 工具栏配置
|
|
const toolbarOptions = ref<any>([
|
|
['bold', 'italic', 'underline', 'strike'], // 加粗 斜体 下划线 删除线
|
|
['blockquote', 'code-block'], // 引用 代码块
|
|
[{ header: 1 }, { header: 2 }], // 1、2 级标题
|
|
[{ list: 'ordered' }, { list: 'bullet' }], // 有序、无序列表
|
|
[{ script: 'sub' }, { script: 'super' }], // 上标/下标
|
|
[{ indent: '-1' }, { indent: '+1' }], // 缩进
|
|
// [{'direction': 'rtl'}], // 文本方向
|
|
[{ size: ['small', false, 'large', 'huge'] }], // 字体大小
|
|
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
|
|
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
|
|
[{ font: [] }], // 字体种类
|
|
[{ align: [] }], // 对齐方式
|
|
])
|
|
|
|
const editorOption = ref<any>({
|
|
// 编辑框操作事件
|
|
theme: 'snow', // or 'bubble'
|
|
placeholder: '请输入资讯内容...',
|
|
modules: {
|
|
toolbar: {
|
|
container: toolbarOptions,
|
|
},
|
|
},
|
|
})
|
|
const dataForm = ref<any>({
|
|
id: '',
|
|
xwbt: '',
|
|
fbt: '',
|
|
nr: '222222',
|
|
flag: '',
|
|
})
|
|
|
|
const editorInstance = ref(null)
|
|
const onEditorReady = (editor) => {
|
|
editorInstance.value = editor
|
|
// 如果 addAndEditForm.content 已经有值,手动设置编辑器内容
|
|
if (addAndEditForm.content) {
|
|
editorInstance.value.setContents(addAndEditForm.content)
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
getContractListData()
|
|
|
|
uploadUrlTemp.value = window.location.origin + '/iws/mall-view/contract-template-250224.docx'
|
|
// getEquipmentTypeApi().then((res: any) => {
|
|
// deviceTypeTree.value = res.data
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
:deep.editor {
|
|
height: 300px;
|
|
}
|
|
:deep.upload-tip .el-form-item__label {
|
|
color: transparent;
|
|
}
|
|
.el-pagination {
|
|
justify-content: flex-end;
|
|
padding: 5px 0;
|
|
}
|
|
:deep.el-pagination.is-background .el-pager li.is-active {
|
|
background-color: #3cb4a6;
|
|
}
|
|
:deep.el-form--inline .el-form-item {
|
|
margin-right: 6px;
|
|
width: 95%;
|
|
}
|
|
|
|
.img-list {
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
.img-items {
|
|
width: 120px;
|
|
height: 120px;
|
|
margin-right: 8px;
|
|
position: relative;
|
|
|
|
img {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.mask-img {
|
|
visibility: hidden;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: #000;
|
|
opacity: 0.5;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
.delete-icon {
|
|
font-size: 20px;
|
|
cursor: pointer;
|
|
z-index: 9;
|
|
color: #fff;
|
|
}
|
|
}
|
|
}
|
|
.img-items:hover .mask-img {
|
|
visibility: visible;
|
|
}
|
|
}
|
|
|
|
.app-container-content {
|
|
:deep(.el-dialog) {
|
|
display: flex !important;
|
|
flex-direction: column !important;
|
|
margin: 0 !important;
|
|
position: absolute !important;
|
|
top: 50% !important;
|
|
left: 50% !important;
|
|
transform: translate(-50%, -50%) !important;
|
|
max-height: 100vh !important;
|
|
.el-dialog__body {
|
|
flex: 1;
|
|
overflow-y: scroll !important;
|
|
}
|
|
.dialog-content {
|
|
padding: 20px;
|
|
}
|
|
}
|
|
}
|
|
|
|
:deep(.el-overlay) {
|
|
z-index: 99 !important;
|
|
}
|
|
</style>
|