Browse Source

修改组件

develop
zq 2 months ago
parent
commit
a0ec9e559c
  1. 68
      examples/package-lock.json
  2. 1
      package.json
  3. 20
      packages/GuipRadio/src/index.vue
  4. 225
      packages/GuipTable/src/index.vue

68
examples/package-lock.json

@ -30,11 +30,12 @@
},
"..": {
"name": "@zhicheng1012/zhicheng-components",
"version": "1.0.25",
"version": "1.0.26",
"license": "MIT",
"dependencies": {
"async-validator": "^1.11.5",
"core-js": "^3.40.0"
"core-js": "^3.40.0",
"vue-clickaway": "^2.2.2"
},
"devDependencies": {
"babel-eslint": "~10.1.0",
@ -3218,12 +3219,13 @@
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="
},
"node_modules/@zhicheng1012/zhicheng-components": {
"version": "1.0.25",
"resolved": "https://registry.npmjs.org/@zhicheng1012/zhicheng-components/-/zhicheng-components-1.0.25.tgz",
"integrity": "sha512-oo6QqLy71T2Ak9NWGjzl8r1TVCCL3PNgvTUtWKrD4i3edtlv/3cFMrTAbZEjC3kJ6Despupj7YvgjXLaGKX0hw==",
"version": "1.0.26",
"resolved": "https://registry.npmjs.org/@zhicheng1012/zhicheng-components/-/zhicheng-components-1.0.26.tgz",
"integrity": "sha512-An3vGczA7RMaJM+HG/SUWknSzLtG5+orG4ZK1Bl5O/PxQbvcXqlO6zLfXGO2qJ1mkD8568PrM9cg69fdMsrr/A==",
"dependencies": {
"async-validator": "^1.11.5",
"core-js": "^3.40.0"
"core-js": "^3.40.0",
"vue-clickaway": "^2.2.2"
},
"engines": {
"node": ">=12.0.0 <=16.x",
@ -9780,8 +9782,7 @@
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"node_modules/js-yaml": {
"version": "3.14.1",
@ -10175,6 +10176,17 @@
"url": "https://tidelift.com/funding/github/npm/loglevel"
}
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
"bin": {
"loose-envify": "cli.js"
}
},
"node_modules/lower-case": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz",
@ -15788,6 +15800,17 @@
"integrity": "sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ==",
"deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details."
},
"node_modules/vue-clickaway": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/vue-clickaway/-/vue-clickaway-2.2.2.tgz",
"integrity": "sha512-25SpjXKetL06GLYoLoC8pqAV6Cur9cQ//2g35GRFBV4FgoljbZZjTINR8g2NuVXXDMLSUXaKx5dutgO4PaDE7A==",
"dependencies": {
"loose-envify": "^1.2.0"
},
"peerDependencies": {
"vue": "^2.0.0"
}
},
"node_modules/vue-eslint-parser": {
"version": "7.11.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.11.0.tgz",
@ -19478,12 +19501,13 @@
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="
},
"@zhicheng1012/zhicheng-components": {
"version": "1.0.25",
"resolved": "https://registry.npmjs.org/@zhicheng1012/zhicheng-components/-/zhicheng-components-1.0.25.tgz",
"integrity": "sha512-oo6QqLy71T2Ak9NWGjzl8r1TVCCL3PNgvTUtWKrD4i3edtlv/3cFMrTAbZEjC3kJ6Despupj7YvgjXLaGKX0hw==",
"version": "1.0.26",
"resolved": "https://registry.npmjs.org/@zhicheng1012/zhicheng-components/-/zhicheng-components-1.0.26.tgz",
"integrity": "sha512-An3vGczA7RMaJM+HG/SUWknSzLtG5+orG4ZK1Bl5O/PxQbvcXqlO6zLfXGO2qJ1mkD8568PrM9cg69fdMsrr/A==",
"requires": {
"async-validator": "^1.11.5",
"core-js": "^3.40.0"
"core-js": "^3.40.0",
"vue-clickaway": "^2.2.2"
},
"dependencies": {
"async-validator": {
@ -24419,8 +24443,7 @@
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"js-yaml": {
"version": "3.14.1",
@ -24748,6 +24771,14 @@
"integrity": "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==",
"dev": true
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"requires": {
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lower-case": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz",
@ -25101,6 +25132,7 @@
"style-loader": "~2.0.0",
"url-loader": "^4.1.1",
"vue": "2.6.14",
"vue-clickaway": "^2.2.2",
"vue-loader": "^15.9.8",
"vue-svg-loader": "^0.16.0",
"vue-template-compiler": "2.6.14",
@ -29231,6 +29263,14 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.14.tgz",
"integrity": "sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ=="
},
"vue-clickaway": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/vue-clickaway/-/vue-clickaway-2.2.2.tgz",
"integrity": "sha512-25SpjXKetL06GLYoLoC8pqAV6Cur9cQ//2g35GRFBV4FgoljbZZjTINR8g2NuVXXDMLSUXaKx5dutgO4PaDE7A==",
"requires": {
"loose-envify": "^1.2.0"
}
},
"vue-eslint-parser": {
"version": "7.11.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.11.0.tgz",

1
package.json

@ -1,6 +1,7 @@
{
"name": "@zhicheng1012/zhicheng-components",
"version": "1.0.26",
"private": true,
"description": "A Vue 2 component library",
"main": "dist/js/zhicheng-components.umd.js",
"publishConfig": {

20
packages/GuipRadio/src/index.vue

@ -138,10 +138,16 @@ export default {
//
const isSelected = this.getValue(option) === this.selectedValue;
// selectedLabellabelKey
return isSelected && option[this.selectedLabelKey]
? option[this.selectedLabelKey]
: option[this.labelKey] || option;
// selectedLabel
if (isSelected && option[this.selectedLabelKey]) {
return option[this.selectedLabelKey];
}
// labelKey
if (typeof option === 'object' && this.labelKey in option) {
return option[this.labelKey];
}
return option;
},
getValue(option) {
//
@ -149,7 +155,11 @@ export default {
return option.key;
}
return option[this.valueKey] || option;
// valueKey
if (typeof option === 'object' && this.valueKey in option) {
return option[this.valueKey];
}
return option;
},
//
isDisabled(key) {

225
packages/GuipTable/src/index.vue

@ -1,96 +1,145 @@
<template>
<el-table
class="guip-table"
ref="guiptable"
v-bind="$attrs"
:data="tableData"
v-on="$listeners"
:border="border"
@selection-change="handleSelectionChange"
:style="{ width: width || '100%', height: height || '100%' }"
v-loading="loading">
<!-- 多选列 -->
<el-table-column
v-if="multiple"
type="selection"
width="55">
</el-table-column>
<!-- 优先使用插槽内容 -->
<slot>
<!-- 如果没有插槽内容则使用 columns 渲染 -->
<template v-if="columns">
<el-table-column
v-for="column in columns"
:key="column.prop"
:prop="column.prop"
:label="column.label"
:width="column.width">
<template #default="{ row }" v-if="column.popover">
<el-popover :visible="row[`popoverVisible_${column.prop}`]" placement="top" trigger="click">
<slot :name="`popover-content-${column.prop}`" :row="row" :column="column">
<div>
<p>默认内容{{ `popoverVisible_${column.prop}` }}</p>
<el-input v-model="row[`edit_${column.prop}`]" :placeholder="`请输入${column.label}`" />
</div>
</slot>
<div class="flex" style="text-align: right; margin-top: 32px;justify-content: flex-end;">
<GuipButton size="medium" @click="handleCancel(row, column.prop)">取消</GuipButton>
<GuipButton type="primary" @click="handleConfirm(row, column.prop)" size="medium">确定</GuipButton>
</div>
<template #reference>
<span style="cursor: pointer">{{ row[column.prop] }}</span>
</template>
</el-popover>
</template>
</el-table-column>
</template>
</slot>
<template #empty>
<el-empty :image="emptyImg"></el-empty>
</template>
</el-table>
<div class="table-container">
<el-table ref="guiptable" v-bind="$attrs" :data="tableData" v-on="$listeners" :border="border" @selection-change="handleSelectionChange"
:style="{ width: width ? width : '100%', height: height ? height : '100%' }" v-loading="loading" empty-text=" ">
<!-- 多选 -->
<template v-if="multiple">
<el-table-column type="selection" width="55">
</el-table-column>
</template>
<!-- 自定义header -->
<slot></slot>
<!-- 通过json数据遍历渲染 -->
<template v-if="columns">
<el-table-column v-for="column in columns" :key="column.prop" :prop="column.prop" :label="column.label"
:width="column.width">
<template #default="{ row }" v-if="column.popover">
<el-popover :visible="row[`popoverVisible_${column.prop}`]" class="tablePopover" placement="top"
trigger="click">
<!-- 自定义内容插槽 -->
<slot :name="`popover-content-${column.prop}`" :row="row" :column="column">
<div>
<p>默认内容{{ `popoverVisible_${column.prop}` }}</p>
<el-input v-model="row[`edit_${column.prop}`]" :placeholder="`请输入${column.label}`" />
</div>
</slot>
<!-- 确定和取消按钮 -->
<div class="flex" style="text-align: right; margin-top: 32px;justify-content: flex-end;">
<GuipButton size="medium" @click="handleCancel(row, column.prop)">取消</GuipButton>
<GuipButton type="primary" @click="handleConfirm(row, column.prop)" size="medium">确定</GuipButton>
</div>
<!-- 单元格内容 -->
<template #reference>
<span style="cursor: pointer">{{ row[column.prop] }}</span>
</template>
</el-popover>
</template>
</el-table-column>
</template>
</el-table>
<div v-if="tableData && tableData.length === 0" class="custom-empty">
<img :src="emptyImg" alt="无数据" />
<p>暂无数据</p>
</div>
</div>
</template>
<script>
import GuipButton from '../../GuipButton/src/index.vue';
export default {
name: 'GuipTable',
props: {
tableData: Array,
loading: Boolean,
width: String,
height: String,
columns: Array,
border: Boolean,
multiple: Boolean
},
components: {
GuipButton
},
data() {
return {
emptyImg: require('../../assets/table_empty.png')
}
},
methods: {
handleSelectionChange(row) {
this.$emit('selectChange', row)
},
handleConfirm(row, prop) {
row[prop] = row[`edit_${prop}`];
row[`popoverVisible_${prop}`] = false;
this.$emit('confirm', row, prop);
},
handleCancel(row, prop) {
row[`edit_${prop}`] = row[prop];
row[`popoverVisible_${prop}`] = false;
this.$emit('cancel', row, prop);
}
}
name: 'GuipTextarea',
props: ['tableData', 'loading', 'width', 'height', 'autoColumn', 'columns', 'border', 'multiple'],
data() {
return {
emptyImg:require('../../assets/table_empty.png')
// loading:false
}
},
components: {
GuipButton,
},
mounted() {
},
methods: {
handleSelectionChange(row) {
//
console.log(row, '======');
this.$emit('selectChange', row)
},
//
handleConfirm(row, prop) {
//
row[prop] = row[`edit_${prop}`];
row[`popoverVisible_${prop}`] = false; //
this.$emit('confirm', row, prop); //
},
//
handleCancel(row, prop) {
//
row[`edit_${prop}`] = row[prop];
row[`popoverVisible_${prop}`] = false; //
this.$emit('cancel', row, prop); //
},
}
}
</script>
<style scoped lang="scss">
/* 外层容器需设为 relative,以便空状态定位 */
.table-container {
position: relative;
width: 100%;
}
/* 空状态固定定位(不随滚动移动) */
.custom-empty {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -35%);
width: 200px;
text-align: center;
background-color: #fff; /* 避免透明背景被表格线干扰 */
// padding: 20px;
z-index: 10; /* 确保显示在表格上方 */
img{
width: 80px;
height: 80px;
}
p{
font-size: 12px;
font-weight: normal;
line-height: 13px;
letter-spacing: 0.08em;
color: #626573;
}
}
/* 确保表格有最小高度(避免高度塌陷) */
.el-table ::v-deep .el-table__body-wrapper {
min-height: 162px !important;
}
.empty-image {
width: 160px;
height: 160px;
}
.empty-text {
color: #626573;
letter-spacing: 0.08em;
height: 18px;
line-height: 18px;
}
.el-empty{
padding: 0;
}
.guip-table ::v-deep .el-empty__description{
line-height: 20px;
margin-top: 0;
}
</script>
</style>

Loading…
Cancel
Save