Browse Source

首次上传

master
ruanqi 2 years ago
parent
commit
85bc3f46ec
  1. 133
      src/views/modules/factory/tblbasedata-add-or-update.vue
  2. 554
      src/views/modules/factory/tblbasedata.vue

133
src/views/modules/factory/tblbasedata-add-or-update.vue

@ -0,0 +1,133 @@
<template>
<el-dialog
v-drag
width="200px"
:title="!dataForm.id ? buttons.add :buttons.edit"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form label-position="top" ref="dataForm"
label-width="80px">
<el-form-item :label="buttons.site || '工厂编号'" prop="baseData">
<el-input v-model="dataForm.baseData" style="width: 160px"></el-input>
</el-form-item>
<el-form-item :label="buttons.siteDesc || '工厂描述'" prop="baseDesc">
<el-input v-model="dataForm.baseDesc" style="width: 160px"></el-input>
</el-form-item>
<el-form-item :label="buttons.siteRemark || '工厂备注'" prop="remark">
<el-input v-model="dataForm.remark" style="width: 160px"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">{{buttons.submit ||'确定'}}</el-button>
<el-button type="primary" @click="visible = false">{{ buttons.close|| '关闭' }}</el-button>
</span>
</el-dialog>
</template>
<script>
import {
searchSysLanguageParam,
searchFunctionButtonList,
saveButtonList,
} from "@/api/sysLanguage.js"
export default {
data() {
return {
visible: false,
dataForm: {
id: 0,
site: 'ALL',
type: '',
secondType: 'site_code',
baseData: '',
baseDesc: '',
status: '1',
sortNo: '',
remark: '',
},
buttons: {
submit: '确定',
add: '添加',
edit: '添加',
close: '关闭',
site:'工厂编号',
siteDesc:'工厂描述',
siteRemark:'工厂备注',
},
}
},
methods: {
init(id, baseColumns) {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/factory/tblbasedata/info/` + this.dataForm.id),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.site = data.data.site
this.dataForm.type = data.data.type
this.dataForm.secondType = data.data.secondType
this.dataForm.baseData = data.data.baseData
this.dataForm.baseDesc = data.data.baseDesc
this.dataForm.status = data.data.status
this.dataForm.sortNo = data.data.sortNo
this.dataForm.remark = data.data.remark
}
})
}
})
},
//
dataFormSubmit() {
if (!this.dataForm.baseData) this.$message.error('工厂编号不能为空'); return
if (!this.dataForm.baseDesc) this.$message.error('工厂描述不能空'); return
this.$http({
url: this.$http.adornUrl(`/factory/tblbasedata/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'site': this.dataForm.site,
'type': this.dataForm.type,
'secondType': this.dataForm.secondType,
'baseData': this.dataForm.baseData,
'baseDesc': this.dataForm.baseDesc,
'status': this.dataForm.status,
'sortNo': this.dataForm.sortNo,
'remark': this.dataForm.remark
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message.success( '操作成功')
this.visible = false
this.$emit('refreshDataList')
} else {
this.$message.error(data.msg)
}
})
},
getFunctionButtonList() {
let queryButton = {
functionId: '998001',
tableId: '*',
languageCode: this.$i18n.locale,
objectType: 'button'
}
searchFunctionButtonList(queryButton).then(({data}) => {
if (data.code == 0 && data.data) {
this.buttons = data.data
}
})
},
},
created() {
this.getFunctionButtonList()
}
}
</script>

554
src/views/modules/factory/tblbasedata.vue

@ -0,0 +1,554 @@
<template>
<div class="mod-config">
<div>
<span @click="favoriteFunction()">
<icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
</span>
</div>
<el-button @click="searchList()" type="primary">{{ buttons.search }}</el-button>
<el-button @click="addOrUpdateHandle(0)" type="primary">{{ buttons.add }}</el-button>
<download-excel
:fields="fields()"
:data="exportData"
type="xls"
:name="exportName"
:header="exportHeader"
:footer="exportFooter"
:fetch="createExportData"
:before-generate="startDownload"
:before-finish="finishDownload"
worksheet="导出信息"
class="el-button el-button--primary el-button--medium">
{{ buttons.download }}
</download-excel>
<el-form v-show="searchShow" :inline="true" :model="queryData" @keyup.enter.native="getDataList()">
<el-form-item label="工厂编辑">
<el-input filterable v-model="queryData.key" clearable>
</el-input>
</el-form-item>
</el-form>
<el-table
:height="height"
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
v-for="(item,index) in columnList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed==''?false:item.fixed"
min-width="20%"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{buttons.edit || '修改' }}</a>
<a type="text" size="small" @click="deleteHandle(scope.row.id)">{{buttons.delete || '删除'}}</a>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 设置查询条件 -->
<search v-if="searchVisible" v-on:childByValue="childByValue" ref="search" @refreshDataList="getDataList"></search>
<!-- 设置列 -->
<column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import column from "../common/column";
import search from "../common/search";
import {
searchSysLanguageParam,
searchFunctionButtonList,
saveButtonList,
} from "@/api/sysLanguage.js"
import {
saveTableDefaultList,
getTableDefaultListLanguage,
getTableUserListLanguage
} from "@/api/table.js"
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
import AddOrUpdate from './tblbasedata-add-or-update'
export default {
data() {
return {
searchVisible: false,
searchShow: false,
queryData: {
key: ''
},
// table
height: 450,
//
favorite: false,
addLanguage: false,
functionId: this.$route.meta.menuId,
tableId: "9002Blbasedata",
languageCode: this.$i18n.locale,
visible: false,
showDefault: false,
//
sysLanguageParams: [],
// table
userColumnList: [],
columnList: [
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataId',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "id",
headerAlign: "center",
align: "left",
columnLabel: "工厂id",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 50
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataSite',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "site",
headerAlign: "center",
align: "left",
columnLabel: "site",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataType',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "sortNo",
headerAlign: "type",
align: "left",
columnLabel: "type",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataSecondType',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "secondType",
headerAlign: "center",
align: "left",
columnLabel: "secondType",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataBaseData',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "baseData",
headerAlign: "center",
align: "left",
columnLabel: "工厂编号",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataBaseDesc',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "baseDesc",
headerAlign: "center",
align: "left",
columnLabel: "工厂描述",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataStatus',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "status",
headerAlign: "status",
align: "left",
columnLabel: "status",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataSortNo',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "sortNo",
headerAlign: "center",
align: "left",
columnLabel: "sortNo",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
{
userId: this.$store.state.user.name,
functionId: this.$route.meta.menuId,
serialNumber: '9002tBlbasedataRemark',
tableId: "9002Blbasedata",
tableName: "工厂信息",
columnProp: "remark",
headerAlign: "center",
align: "left",
columnLabel: "工厂备注",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: false
},
],
//
dataList: [],
buttons: {
add: '添加',
edit: '编辑',
delete: '删除',
deleteList: '批量删除',
cz: '操作',
search: '搜索',
download: '导出',
settingTable: '设置列表',
defaultTable: '设置默认配置',
site:'工厂编号',
siteDesc:'工厂描述',
siteRemark:'工厂备注',
},
// start
exportData: [],
exportName: "工厂列表" + this.dayjs().format('YYYYMMDDHHmmss'),
exportHeader: ["工厂列表"],
exportFooter: [],
// end
//
pageIndex: 1,
pageSize: 20,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false,
}
},
components: {
AddOrUpdate,
column,
search
},
mounted() {
this.$nextTick(() => {
this.height = window.innerHeight - 240;
})
},
activated() {
this.getDataList()
},
methods: {
childByValue(childValue) {
// childValue
console.log(childValue)
let json = "{"
childValue.forEach((item, index) => {
if (index == childValue.length - 1) {
json += "\"" + item.queryAttributes + "\"" + ":" + "\"" + item.queryValue + "\""
} else {
json += "\"" + item.queryAttributes + "\"" + ":" + "\"" + item.queryValue + "\"" + ","
}
})
json += "}"
let s = eval("(" + json + ")")
console.log(json)
},
//
searchList() {
this.searchVisible = true;
let queryTable = {
userId: this.userId,
functionId: this.functionId,
tableId: this.tableId,
languageCode: this.languageCode
}
this.$nextTick(() => {
this.$refs.search.init(queryTable);
});
},
//
favoriteIsOk() {
let userFavorite = {
userId: this.$store.state.user.id,
languageCode: this.$i18n.locale
}
userFavoriteList(userFavorite).then(({data}) => {
let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
if (size > 0) {
this.favorite = true
} else {
this.favorite = false
}
})
},
// OR
favoriteFunction() {
let userFavorite = {
userId: this.$store.state.user.id,
functionId: this.$route.meta.menuId,
}
if (this.favorite) {
//
this.$confirm(`确定取消收藏`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
removeUserFavorite(userFavorite).then(({data}) => {
this.$message.success(data.msg)
this.favorite = false
})
})
} else {
//
saveUserFavorite(userFavorite).then(({data}) => {
this.$message.success(data.msg)
this.favorite = true
})
}
},
// button
getFunctionButtonList() {
let queryButton = {
functionId: this.functionId,
tableId: '*',
languageCode: this.languageCode,
objectType: 'button'
}
searchFunctionButtonList(queryButton).then(({data}) => {
if (data.code == 0 && data.data) {
this.buttons = data.data
}
})
},
//
getTableUserColumn() {
let queryTableUser = {
userId: this.userId,
functionId: this.functionId,
tableId: this.tableId,
languageCode: this.languageCode,
status: true,
}
getTableUserListLanguage(queryTableUser).then(({data}) => {
if (data.code == 0 && data.data) {
//this.columnList = []
this.columnList = data.rows
} else {
this.getColumnList()
}
})
},
// tableDefault
getColumnList() {
let queryTable = {
functionId: this.functionId,
tableId: this.tableId,
languageCode: this.languageCode
}
getTableDefaultListLanguage(queryTable).then(({data}) => {
if (data.code == 0 && data.data ) {
// this.showDefault = false
this.columnList = data.rows
} else {
// this.showDefault = true
}
})
},
//
getDataList() {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/factory/tblbasedata/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.queryData.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.list
this.totalPage = data.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
//
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
//
currentChangeHandle(val) {
this.pageIndex = val
this.getDataList()
},
//
selectionChangeHandle(val) {
this.dataListSelections = val
},
// /
addOrUpdateHandle(id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
//
deleteHandle(id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定删除选择中的数据`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/factory/tblbasedata/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message.success('操作成功')
this.getDataList()
} else {
this.$message.error(data.msg)
}
})
})
},
//
fields() {
let json = "{"
this.columnList.forEach((item, index) => {
if (index == this.columnList.length - 1) {
json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
} else {
json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
}
})
json += "}"
let s = eval("(" + json + ")")
return s
},
createExportData() {
// ,,
// TODO:
if (this.dataListSelections.length > 0) {
return this.dataListSelections;
}
return this.dataList;
},
startDownload() {
// this.exportData = this.dataList
},
finishDownload() {
}
},
created() {
this.getTableUserColumn()
this.getFunctionButtonList()
this.favoriteIsOk()
}
}
</script>
<style scoped>
.sl-svg {
overflow: hidden;
float: right;
}
</style>
Loading…
Cancel
Save