pref(cmdb-ui):batch upload for date type (#298)

* fix(cmdb-ui):set localstorage '' after unsubscribe ci

* pref(cmdb-ui):batch upload for date type
This commit is contained in:
wang-liang0615 2023-12-12 13:38:08 +08:00 committed by GitHub
parent 64f891df31
commit 6c45ca7cb0
4 changed files with 20 additions and 3 deletions

View File

@ -7,7 +7,7 @@ export function processFile(fileObj) {
reader.readAsBinaryString(fileObj) reader.readAsBinaryString(fileObj)
reader.onload = function (e) { reader.onload = function (e) {
const data = e.target.result const data = e.target.result
const workbook = XLSX.read(data, { type: 'binary' }) const workbook = XLSX.read(data, { type: 'binary', cellDates: true, })
const sheet = workbook.Sheets[workbook.SheetNames[0]] const sheet = workbook.Sheets[workbook.SheetNames[0]]
const lt = XLSX.utils.sheet_to_json(sheet, { header: 1 }) const lt = XLSX.utils.sheet_to_json(sheet, { header: 1 })
resolve(lt) resolve(lt)
@ -56,7 +56,6 @@ export function any(ArrayList) {
// 去除一个二维数组 底下为空的部分 // 去除一个二维数组 底下为空的部分
export function filterNull(twoDimArray) { export function filterNull(twoDimArray) {
console.log(twoDimArray)
const newArray = [] const newArray = []
for (let i = 0; i < twoDimArray.length; i++) { for (let i = 0; i < twoDimArray.length; i++) {
if (any(twoDimArray[i])) { if (any(twoDimArray[i])) {

View File

@ -29,6 +29,7 @@
</template> </template>
<script> <script>
import moment from 'moment'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import CiTypeChoice from './modules/CiTypeChoice' import CiTypeChoice from './modules/CiTypeChoice'
import CiUploadTable from './modules/CiUploadTable' import CiUploadTable from './modules/CiUploadTable'
@ -73,6 +74,22 @@ export default {
const _ele = {} const _ele = {}
item.forEach((ele, j) => { item.forEach((ele, j) => {
if (ele !== undefined && ele !== null) { if (ele !== undefined && ele !== null) {
const _find = this.ciTypeAttrs.attributes.find(
(attr) => attr.alias === dataList[0][j] || attr.name === dataList[0][j]
)
if (_find?.value_type === '4') {
_ele[dataList[0][j]] = moment(ele).add(1, 'days').format('YYYY-MM-DD')
} else if (_find?.value_type === '3') {
_ele[dataList[0][j]] = moment(ele)
.add(43, 'seconds')
.format('YYYY-MM-DD HH:mm:ss')
} else if (_find?.value_type === '5') {
_ele[dataList[0][j]] = moment(ele)
.subtract(5, 'minutes')
.format('HH:mm:ss')
} else {
_ele[dataList[0][j]] = ele
}
_ele[dataList[0][j]] = ele _ele[dataList[0][j]] = ele
} }
}) })

View File

@ -8,6 +8,7 @@
class="ops-stripe-table" class="ops-stripe-table"
:max-height="200" :max-height="200"
:data="dataSource" :data="dataSource"
resizable
> >
<vxe-column type="seq" width="40" /> <vxe-column type="seq" width="40" />
<vxe-column <vxe-column

View File

@ -372,7 +372,7 @@ export default {
}, },
async open(property, attrList) { async open(property, attrList) {
this.visible = true this.visible = true
this.getNoticeConfigAppBot() await this.getNoticeConfigAppBot()
this.attrList = attrList this.attrList = attrList
if (property.has_trigger) { if (property.has_trigger) {
this.triggerId = property.trigger.id this.triggerId = property.trigger.id