Commit 7713359e authored by hiyonx's avatar hiyonx

sap input提交

parent 887a43fa
<template>
<div class="el-input-all">
<el-input v-if="item.dataType === 1" v-model="value" :placeholder="'请输入' + item.name" clearable :disabled="!!item.relationField"/>
<el-input-number v-if="item.dataType === 2" v-model="value" :placeholder="'请输入' + item.name" clearable :disabled="!!item.relationField"/>
<el-input-money v-if="item.dataType === 3" v-model="value" :placeholder="'请输入' + item.name" clearable :disabled="!!item.relationField"/>
<el-date-picker v-if="item.dataType === 4" v-model="value" :placeholder="'请选择' + item.name" clearable :disabled="!!item.relationField" type="date"/>
<el-time-picker v-if="item.dataType === 5" v-model="value" :placeholder="'请选择' + item.name" clearable :disabled="!!item.relationField"/>
<el-date-picker v-if="item.dataType === 6" v-model="value" :placeholder="'请选择' + item.name" clearable :disabled="!!item.relationField" type="datetime"/>
<el-select v-if="item.dataType === 7" v-model="value" :placeholder="'请选择' + item.name" clearable filterable :disabled="!!item.relationField">
<el-option v-for="option in item.dictDataList" :key="option.id" :value="option.value" :label="option.name"/>
</el-select>
</div>
</template>
<script>
export default {
name: 'ElInputAll',
model: {
prop: 'val',
event: 'update',
},
props: {
val: {type: [Number, String, Date, Array, Object]},
item: {type: Object, required: true},
},
computed: {
value: {
get() {
return this.val
},
set(val) {
this.$emit('update', val)
}
}
},
data() {
return {}
},
methods: {},
created() {
}
}
</script>
<style scoped>
</style>
......@@ -67,16 +67,6 @@ export default {
this.money = this.formatMoney(this.value * this.unit);
}
},
/**
* 格式化金钱
*/
formatMoney(val) {
if (val === '' || val == null) return null
let str = (+val).toFixed(2);
let intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{3})+$)/g, ',');//取到整数部分
let dot = str.substring(str.length, str.indexOf("."))//取到小数部分搜索
return '¥ ' + intSum + dot;
},
}
}
</script>
......
......@@ -18,7 +18,7 @@ import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree, formatMoney } from "@/utils/ruoyi";
import PageTitle from '@/components/Page/PageTitle.vue'
......@@ -31,6 +31,8 @@ import RightToolbar from "@/components/RightToolbar"
import Editor from "@/components/Editor"
// 金钱输入框
import ElInputMoney from "@/components/ElInputMoney"
// sap输入框
import ElInputAll from "@/components/ElInputAll"
// 文件上传组件
import FileUpload from "@/components/FileUpload"
// 图片上传组件
......@@ -56,6 +58,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.formatMoney = formatMoney
// 全局组件挂载
Vue.component('PageWrapper', PageWrapper)
......@@ -65,6 +68,7 @@ Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)
Vue.component('ElInputMoney', ElInputMoney)
Vue.component('ElInputAll', ElInputAll)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
......
......@@ -68,7 +68,7 @@ export function addDateRange(params, dateRange, propName) {
return search;
}
// 回显数据字典
// 回显数据字典
export function selectDictLabel(datas, value) {
if (value === undefined) {
return "";
......@@ -233,4 +233,15 @@ export async function blobValidate(data) {
} catch (error) {
return true;
}
}
\ No newline at end of file
}
/**
* 格式化金钱
*/
export function formatMoney(val, prefix = '¥ ') {
if (val === '' || val == null) return null
let str = Number(val).toFixed(2);
let intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{3})+$)/g, ',');//取到整数部分
let dot = str.substring(str.length, str.indexOf("."))//取到小数部分搜索
return prefix + intSum + dot;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment