qms/src/views/modules/customerquality/qmsKnowledgeBase.vue
‘937886381’ b810720fbd 修改bug
2023-07-19 09:23:37 +08:00

324 lines
9.8 KiB
Vue

<!--
* @Author: zhp
* @Date: 2023-06-08 14:29:46
* @LastEditTime: 2023-07-18 14:20:57
* @LastEditors: zhp
* @Description:
-->
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-sys__user">
<SearchBar :formConfigs="formConfig" ref="ruleForm" @headBtnClick="buttonClick">
<!-- <el-badge :value="2" class="item">
<el-button type="primary" size="small" @click="conditionSearch">条件搜索</el-button>
</el-badge> -->
</SearchBar>
<base-table id="palletTable" :table-props="tableProps" :page="listQuery.page" ref="palletTable1"
:limit="listQuery.limit" :table-data="tableData">
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="100" label="操作" :method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination :limit.sync="listQuery.limit" :page.sync="listQuery.page" :total="listQuery.total"
@pagination="getDataList" />
<!-- 弹窗, 新增 / 修改 -->
<base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="addOrUpdateVisible" @cancel="handleCancel"
@confirm="handleConfirm" :before-close="handleCancel">
<qmsKnowledgeBase-add ref="addOrUpdate" @refreshDataList="successSubmit">
</qmsKnowledgeBase-add>
<!-- <el-row slot="footer" type="flex" justify="end"> </el-row> -->
</base-dialog>
<baseConfig ref="baseConfigOrList" v-if="baseConfigShow"></baseConfig>
<!-- <base-dialog :dialogTitle="searchOrEditTitle" :dialogVisible="searchOrUpdateVisible" @cancel="handleSearchCancel"
@confirm="handleSearchConfirm" :before-close="handleSearchCancel">
<projectType-search ref="searchOrUpdate" @successSubmit="conditionSearchSubmit">
</projectType-search>
<el-row slot="footer" type="flex" justify="end">
<el-col :span="12">
<el-button size="small" type="primary" plain class="btnTextStyle" @click="handleSearchCancel">
{{ $t("close") }}
</el-button>
<el-button size="small" class="btnTextStyle" type="primary" plain @click="handleSearchReset">{{
$t("reset")
}}</el-button>
<el-button type="primary" size="small" class="btnTextStyle" @click="handleSearchConfirm">
{{ $t("search") }}
</el-button>
</el-col>
</el-row>
</base-dialog> -->
</div>
</el-card>
</template>
<script>
import basicPage from "@/mixins/basic-page"
// import basicSearch from "@/mixins/basic-search"
// import projectTypeSearch from "./components/projectTypeSearch.vue"
import customerquality from '@/filters/customerquality'
import qmsKnowledgeBaseAdd from "./components/qmsKnowledgeBase-add.vue"
import baseConfig from "./components/baseConfig"
import i18n from "@/i18n"
// import i18n from "@/i18n";
const tableProps = [
{
prop: "code",
label: i18n.t('customerquality.code'),
},
{
prop: "knowledgeBaseName",
label: i18n.t('customerquality.knowledgeBaseName'),
},
{
prop: "categoryName",
label: i18n.t('customerquality.category'),
}
];
const tableBtn = [
{
type: "edit",
btnName: i18n.t('edit'),
},
{
type: "delete",
btnName: i18n.t('delete'),
},
{
type: "configuration",
btnName: i18n.t('configuration'),
}
];
export default {
mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: "/customerquality/qmsKnowledgeBase/page",
deleteURL: "/customerquality/qmsKnowledgeBase",
exportURL: '/customerquality/qmsKnowledgeBase/export'
},
tableProps,
tableBtn,
productData: {},
dataForm:{
limit: 999,
page:1
},
baseConfigShow:false,
searchOrEditTitle: "",
searchOrUpdateVisible: false,
productOrEditTitle: "",
addOrEditTitle: '',
addOrUpdateVisible: false,
productOrUpdateVisible: false,
formConfig: [
// {
// type: 'input',
// label: i18n.t('customerquality.customerName'),
// placeholder: i18n.t('customerquality.customerName'),
// param: 'customerName'
// },
// {
// type: 'select',
// label: i18n.t('customerquality.questionType'),
// placeholder: i18n.t('customerquality.questionType'),
// selectOptions: [
// {
// id: 0,
// name: '产品质量题'
// },
// {
// id: 1,
// name: '售后服务题'
// },
// {
// id: 2,
// name: '物流配送问题'
// },
// {
// id: 3,
// name: '单关问题'
// },
// {
// id: 4,
// name: '4系统故问题'
// }
// ],
// param: 'questionType'
// },
// {
// type: 'select',
// label: i18n.t('basic.status'),
// placeholder: i18n.t('basic.status'),
// selectOptions: [
// {
// id: 0,
// name: '不可用'
// },
// {
// id: 1,
// name: '可用'
// }
// ],
// param: 'status'
// },
{
type: "button",
btnName: i18n.t('search'),
name: "search",
color: "primary",
// plain: true,
},
{
type: "button",
btnName: i18n.t('add'),
name: "add",
color: "success",
plain:true
}
],
};
},
components: {
qmsKnowledgeBaseAdd,
baseConfig
},
methods: {
//search-bar点击
handleProductCancel() {
this.productOrUpdateVisible = false;
this.productOrEditTitle = "";
},
handleCurrentChange(val) {
console.log(val);
this.productData = val.newVal ? val.newVal : {}
},
setCurrent(index) {
this.$refs.palletTable1.setCurrent("palletTable", index);
},
// handleSearchCancel() {
// this.searchOrEditTitle = "";
// this.searchOrUpdateVisible = false;
// },
conditionSearch() {
this.searchOrEditTitle = "搜索";
this.searchOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.searchOrUpdate.init();
});
},
// handleConfirm() {
// this.$refs.addOrUpdate.dataFormSubmitHandle();
// },
// conditionSearchSubmit() {},
conditionSearchSubmit(dataForm) {
// console.log(key);
// console.log(key);
this.listQuery.page = 1;
this.getDataList();
this.searchOrUpdateVisible = false;
// console.log(11111);
// this.conditionSearchSubmit();
},
exportHandle() {
this.$http.get(this.urlOptions.exportURL, { responseType: 'blob' }, {
...this.dataForm
}).then((res) => {
console.log(res)
// if (res !== 0) {
// return this.$message.error(res.msg)
// }
let fileName = ''
const contentDisposition = res.headers['content-disposition']
if (contentDisposition) {
const temp = res.headers['content-disposition']
.split(';')[1]
.split('=')[1]
// 对文件名乱码转义--【Node.js】使用iconv-lite解决中文乱码
fileName = decodeURI(temp)
console.log(temp)
}
const blob = new Blob([res.data])
const reader = new FileReader()
reader.readAsDataURL(blob)
reader.onload = (e) => {
const a = document.createElement('a')
a.download = fileName
a.href = e.target.result
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
}).catch(() => { })
},
handleClick(val) {
if (val.type === "delete") {
this.$confirm(`确定对[名称=${val.data.customerTypeName}]进行删除操作?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$http.delete(this.urlOptions.deleteURL, { data: [val.data.id] }).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.getDataList();
},
});
} else {
this.$message.error(data.msg);
}
});
})
.catch(() => { });
} else if (val.type === 'edit') {
this.addOrUpdateVisible = true
this.addOrEditTitle = this.$t('edit')
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id);
})
} else if (val.type === 'configuration') {
this.baseConfigShow = true
const obj = {
knowledgeBaseId: val.data.id
}
this.$nextTick(() => {
this.$refs.baseConfigOrList.init(obj)
});
}
},
// addOrUpdateHandle(productData) {
// this.addOrUpdateVisible = true;
// this.$nextTick(() => {
// this.$refs.addOrUpdate.init(productData);
// });
// },
buttonClick(val) {
console.log(val);
switch (val.btnName) {
case "search":
// this.listQuery.paramCode = val.paramCode;
// console.log(i18n);
this.listQuery.page = 1
this.getDataList()
break;
case "export":
this.exportHandle()
break;
case "add":
this.addOrEditTitle = '新增'
this.addOrUpdateVisible = true;
this.addOrUpdateHandle()
break;
default:
}
},
},
};
</script>