|
@@ -18,23 +18,35 @@
|
|
|
有一条待更新记录,待更新值为:{{ item.paramValue }}{{ item.params.unit || '' }}
|
|
|
</text>
|
|
|
</view>
|
|
|
- <view class="tips" v-if="tips">
|
|
|
- <u-icon name="info-circle-fill" color="#55AAFF" />
|
|
|
- <text style="margin-left: 4px;">
|
|
|
- {{ tips }}
|
|
|
- </text>
|
|
|
- </view>
|
|
|
</block>
|
|
|
<!-- 布尔开关 -->
|
|
|
<block v-else-if="item.inputType == 'switch'">
|
|
|
<view class="title u-line-1">
|
|
|
{{ item.funcname || '' }}{{ item.params.unit || '' }}
|
|
|
</view>
|
|
|
- {{ tips }}
|
|
|
+ {{ switchTips }}
|
|
|
</block>
|
|
|
<!-- 步进器 -->
|
|
|
<block v-else-if="item.inputType == 'step'">
|
|
|
- 步进器还没写
|
|
|
+ <view class="title u-line-1">
|
|
|
+ {{ item.funcname }}{{ item.params.unit || '' }}
|
|
|
+ </view>
|
|
|
+ <u-number-box :asyncChange="true" :min="item.params.num_minvalue" :max="item.params.num_maxvalue"
|
|
|
+ :step="item.params.num_step" v-model="value" :decimal-length="item.params.num_scale"
|
|
|
+ @change="stepChange" @focus="stepFocus" @blur="stepBlue" inputWidth="100" />
|
|
|
+ <!-- </view> -->
|
|
|
+ <view class="tips" v-if="item.paramValue">
|
|
|
+ <u-icon name="info-circle-fill" color="#E2201A" />
|
|
|
+ <text style="margin-left: 4px;">
|
|
|
+ 有一条待更新记录,待更新值为:{{ item.paramValue }}{{ item.params.unit || '' }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="tips">
|
|
|
+ <u-icon name="info-circle-fill" color="#E2201A" />
|
|
|
+ <text style="margin-left: 4px;">
|
|
|
+ 受步长限制,手动输入会计算为最接近的合法值
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
</block>
|
|
|
<!-- 时段 -->
|
|
|
<block v-else-if="item.inputType == 'dayParting'">
|
|
@@ -56,18 +68,6 @@
|
|
|
<u--input :focus="dayPartingFocus" v-model="value" type="digit"
|
|
|
:placeholder="item.params[item.key + 'P'].lastvalue || '请输入'" border="surround" />
|
|
|
</view>
|
|
|
- <view class="tips" v-if="toBeUpdated">
|
|
|
- <u-icon name="info-circle-fill" color="#E2201A" />
|
|
|
- <text style="margin-left: 4px;">
|
|
|
- {{ toBeUpdated }}
|
|
|
- </text>
|
|
|
- </view>
|
|
|
- <view class="tips" v-if="tips">
|
|
|
- <u-icon name="info-circle-fill" color="#55AAFF" />
|
|
|
- <text style="margin-left: 4px;">
|
|
|
- {{ tips }}
|
|
|
- </text>
|
|
|
- </view>
|
|
|
</view>
|
|
|
</block>
|
|
|
<!-- 选择 -->
|
|
@@ -82,25 +82,43 @@
|
|
|
{{ op.label }}
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="tips" v-if="toBeUpdated">
|
|
|
- <u-icon name="info-circle-fill" color="#E2201A" />
|
|
|
- <text style="margin-left: 4px;">
|
|
|
- {{ toBeUpdated }}
|
|
|
- </text>
|
|
|
+ </block>
|
|
|
+ <!-- slot -->
|
|
|
+ <block v-else-if="isSlot">
|
|
|
+ <view class="title u-line-1">
|
|
|
+ {{ item.funcname || '' }}
|
|
|
</view>
|
|
|
+ <slot />
|
|
|
</block>
|
|
|
<!-- 其他类型 -->
|
|
|
<block v-else>
|
|
|
其他类型
|
|
|
</block>
|
|
|
+ <view class="tips" v-if="toBeUpdated">
|
|
|
+ <u-icon name="info-circle-fill" color="#E2201A" />
|
|
|
+ <text style="margin-left: 4px;">
|
|
|
+ {{ toBeUpdated }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="tips" v-if="tips">
|
|
|
+ <u-icon name="info-circle-fill" color="#55AAFF" />
|
|
|
+ <text style="margin-left: 4px;">
|
|
|
+ {{ tips }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
-let model = null;
|
|
|
+import currency from "../../utils/currency";
|
|
|
export default {
|
|
|
name: "My_input",
|
|
|
+ props: {
|
|
|
+ customMethod: {
|
|
|
+ type: Function
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
show: false,
|
|
@@ -111,67 +129,103 @@ export default {
|
|
|
dayPartingFocus: false,
|
|
|
value: "",
|
|
|
confirmText: '确定',
|
|
|
- loading: false
|
|
|
+ loading: false,
|
|
|
+ stepIsCalculate: false,
|
|
|
+ isSlot: false,
|
|
|
+ switchTips: ""
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
/**
|
|
|
* @param item.inputType int:数字 step:步进器 radio:单选 switch:开关 dayParting:分时段
|
|
|
*/
|
|
|
- openInput(item) {
|
|
|
- this.item = JSON.parse(JSON.stringify(item))
|
|
|
- this.show = true
|
|
|
- let tips = "";
|
|
|
- this.toBeUpdated = '';
|
|
|
- let params = item.params;
|
|
|
+ openInput(item, isSlot = false) {
|
|
|
+ try {
|
|
|
+ this.item = JSON.parse(JSON.stringify(item))
|
|
|
+ } catch (error) {
|
|
|
+ console.log("item JSON.parse 失败")
|
|
|
+ this.item = item
|
|
|
+ }
|
|
|
+ this.switchTips = "";
|
|
|
+ this.show = true;
|
|
|
+ let tips = "",
|
|
|
+ toBeUpdated = '';
|
|
|
this.confirmText = '确定'
|
|
|
- if (item.inputType == 'int') {
|
|
|
- this.value = "";
|
|
|
- this.intFocus = false;
|
|
|
- if (params.num_minvalue || params.num_maxvalue) tips += `输入范围:${params.num_minvalue || 0} ~ ${params.num_maxvalue || '∞'}`
|
|
|
- if (params.num_scale) tips += `,保留${params.num_scale}位小数`
|
|
|
- if (params.num_step) tips += `,增量${params.num_step || 0}`
|
|
|
- if (tips && params.unit) tips += `,单位${params.unit}`
|
|
|
- setTimeout(() => {
|
|
|
- this.intFocus = true
|
|
|
- }, 300);
|
|
|
- } else if (item.inputType == "switch") {
|
|
|
- let paramValue = item.paramValue + "";
|
|
|
- if (paramValue.length && paramValue != item.params.lastvalue) {
|
|
|
- this.confirmText = '取消修改'
|
|
|
- tips = `查询到“${item.funcname}”有待更新记录,待更新值为“${params.options.find(v => v.value == item.paramValue).label}”;您可通过“${this.confirmText}”按钮取消待更新请求`
|
|
|
+ if (isSlot) {
|
|
|
+ this.isSlot = true;
|
|
|
+ } else {
|
|
|
+ this.isSlot = false;
|
|
|
+ let params = item.params;
|
|
|
+ if (item.inputType == 'int') {
|
|
|
+ this.value = "";
|
|
|
+ this.intFocus = false;
|
|
|
+ if (params.num_minvalue || params.num_maxvalue) tips += `输入范围:${params.num_minvalue || 0} ~ ${params.num_maxvalue || '∞'}`
|
|
|
+ if (params.num_scale) tips += `,保留${params.num_scale}位小数`
|
|
|
+ if (params.num_step) tips += `,增量${params.num_step || 0}`
|
|
|
+ if (tips && params.unit) tips += `,单位${params.unit}`
|
|
|
+ setTimeout(() => {
|
|
|
+ this.intFocus = true
|
|
|
+ }, 300);
|
|
|
+ } else if (item.inputType == "switch") {
|
|
|
+ let paramValue = item.paramValue + "";
|
|
|
+ if (paramValue.length && paramValue != item.params.lastvalue) {
|
|
|
+ this.confirmText = '取消修改'
|
|
|
+ this.switchTips = `查询到“${item.funcname}”有待更新记录,待更新值为“${params.options.find(v => v.value == item.paramValue).label}”;您可通过“${this.confirmText}”按钮取消待更新请求`
|
|
|
+ } else {
|
|
|
+ this.confirmText = '切换'
|
|
|
+ this.switchTips = `是否将“${item.funcname}”${this.confirmText}为:“${params.options.find(v => v.value != item.paramValue).label}”`
|
|
|
+ }
|
|
|
+ } else if (item.inputType == "dayParting") {
|
|
|
+ this.value = item.params[item.key + 'p'];
|
|
|
+ this.dayPartingFocus = false;
|
|
|
+ toBeUpdated = item.paramValue.time || item.paramValue.value ? `查询到一条待更新指令,更新内容为:时间${item.paramValue.time.split("_").join(":")},压力${item.paramValue.value}MPA` : ""
|
|
|
+ let p = item.params[item.key + 'P'];
|
|
|
+ if (p.num_minvalue || p.num_maxvalue) tips += `输入范围:${p.num_minvalue || 0} ~ ${p.num_maxvalue || '∞'}`
|
|
|
+ if (p.num_scale) tips += `,保留${p.num_scale}位小数`
|
|
|
+ if (p.num_step) tips += `,增量${p.num_step || 0}`
|
|
|
+ if (tips && p.unit) tips += `,单位${p.unit}`
|
|
|
+ setTimeout(() => {
|
|
|
+ this.dayPartingFocus = true
|
|
|
+ }, 300);
|
|
|
+ } else if (item.inputType == "radio") {
|
|
|
+ let paramValue = item.paramValue + "";
|
|
|
+ if (paramValue.length && paramValue != item.params.lastvalue) {
|
|
|
+ toBeUpdated = `查询到“${item.funcname}”有待更新记录,待更新值为“${params.options.find(v => v.value == item.paramValue).label}”`
|
|
|
+ }
|
|
|
+ } else if (item.inputType == "step") {
|
|
|
+ this.value = params.lastvalue;
|
|
|
+ if (this.value > params.num_maxvalue) this.value = params.num_maxvalue;
|
|
|
+ if (this.value < params.num_minvalue) this.value = params.num_minvalue;
|
|
|
+ if (params.num_minvalue || params.num_maxvalue) tips += `输入范围:${params.num_minvalue || 0} ~ ${params.num_maxvalue || '∞'}`
|
|
|
+ if (params.num_scale) tips += `,保留${params.num_scale}位小数`
|
|
|
+ if (params.num_step) tips += `,增量${params.num_step || 0}`
|
|
|
+ if (tips && params.unit) tips += `,单位${params.unit}`
|
|
|
+ setTimeout(() => {
|
|
|
+ this.intFocus = true
|
|
|
+ }, 300);
|
|
|
} else {
|
|
|
- this.confirmText = '切换'
|
|
|
- tips = `是否将“${item.funcname}”${this.confirmText}为:“${params.options.find(v => v.value != item.paramValue).label}”`
|
|
|
- }
|
|
|
- } else if (item.inputType == "dayParting") {
|
|
|
- this.value = item.params[item.key + 'p'];
|
|
|
- this.dayPartingFocus = false;
|
|
|
- this.toBeUpdated = item.paramValue.time || item.paramValue.value ? `查询到一条待更新指令,更新内容为:时间${item.paramValue.time.split("_").join(":")},压力${item.paramValue.value}MPA` : ""
|
|
|
- let p = item.params[item.key + 'P'];
|
|
|
- if (p.num_minvalue || p.num_maxvalue) tips += `输入范围:${p.num_minvalue || 0} ~ ${p.num_maxvalue || '∞'}`
|
|
|
- if (p.num_scale) tips += `,保留${p.num_scale}位小数`
|
|
|
- if (p.num_step) tips += `,增量${p.num_step || 0}`
|
|
|
- if (tips && p.unit) tips += `,单位${p.unit}`
|
|
|
- setTimeout(() => {
|
|
|
- this.dayPartingFocus = true
|
|
|
- }, 300);
|
|
|
- } else if (item.inputType == "radio") {
|
|
|
- let paramValue = item.paramValue + "";
|
|
|
- if (paramValue.length && paramValue != item.params.lastvalue) {
|
|
|
- this.toBeUpdated = `查询到“${item.funcname}”有待更新记录,待更新值为“${params.options.find(v => v.value == item.paramValue).label}”`
|
|
|
+ console.log(item)
|
|
|
}
|
|
|
- } else {
|
|
|
- console.log(item)
|
|
|
}
|
|
|
this.tips = tips;
|
|
|
+ this.toBeUpdated = toBeUpdated;
|
|
|
},
|
|
|
onSelected(option, mode) {
|
|
|
- console.log(option, mode)
|
|
|
if (mode == "radio") {
|
|
|
this.item.params.lastvalue = option.value;
|
|
|
}
|
|
|
},
|
|
|
+ stepChange(e) {
|
|
|
+ if (!this.stepIsCalculate) this.value = e.value;
|
|
|
+ },
|
|
|
+ stepFocus(e) {
|
|
|
+ this.stepIsCalculate = true;
|
|
|
+ },
|
|
|
+ stepBlue(e) {
|
|
|
+ const { num_step, num_scale } = this.item.params;
|
|
|
+ this.value = currency(currency(e.value, { increment: num_step, precision: num_scale }).format()).value;
|
|
|
+ this.stepIsCalculate = false;
|
|
|
+ },
|
|
|
/* 时段修改 */
|
|
|
changeT_T(e) {
|
|
|
this.item.params[this.item.key + 'T'].lastvalue = e.detail.value;
|
|
@@ -185,6 +239,7 @@ export default {
|
|
|
},
|
|
|
confirm() {
|
|
|
if (this.loading) return;
|
|
|
+ if (this.isSlot) return this.$emit("customMethod", "confirm")
|
|
|
let item = this.item,
|
|
|
params = item.params,
|
|
|
value = "";
|
|
@@ -303,5 +358,17 @@ export default {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /* 步进器样式 */
|
|
|
+ /deep/ .u-number-box__minus,
|
|
|
+ /deep/.u-number-box__plus {
|
|
|
+ height: 30px !important;
|
|
|
+ width: 40px !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/ .u-number-box__input {
|
|
|
+ height: 30px !important;
|
|
|
+ width: 100px !important;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|