123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <template>
- <view class="wk-field wk-field-select" @click.stop="handleChoose">
- <view v-if="_label" class="wk-field__label">
- <view v-if="field.isNull === 1" class="line" />
- {{ _label }}
- </view>
- <view class="wk-field__body">
- <view class="wk-field__body-core">
- {{ valueStr }}
- </view>
- <text class="wk wk-arrow-right icon-right" />
- </view>
- </view>
- </template>
- <script>
- import mixins from './mixins'
- export default {
- name: 'WkFieldRevelance',
- mixins: [mixins],
- props: {
- req: {
- type: Function,
- default: null
- },
- isDetailTable: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- guid: null,
- formValue: [],
- keyMap: {
- customer: {labelField: 'customerName', valueField: 'customerId'},
- contacts: {labelField: 'contactsName', valueField: 'contactsId'},
- business: {labelField: 'businessName', valueField: 'businessId'},
- contract: {labelField: 'num', valueField: 'contractId'},
- }
- }
- },
- computed: {
- type() {
- return this.field.formType
- },
- valueStr() {
- let obj = null
- if (
- this.config &&
- this.config.optionsConfig &&
- (
- this.config.optionsConfig.labelField ||
- this.config.optionsConfig.valueField
- )
- ) {
- obj = this.config.optionsConfig
- } else {
- obj = this.keyMap[this.type] || {}
- }
- if (this.$isEmpty(obj)) return ''
- // console.log('obj--', obj, this.formValue)
- const key = obj.labelField
- const arr = this.formValue || []
- return arr.map(o => o[key]).join(',')
- },
- list() {
- return this.field.setting.map(o => {
- return {
- label: o,
- value: o
- }
- })
- }
- },
- created() {
- this.guid = this.$guid()
- },
- methods: {
- handleChoose() {
- if (this.field.disabled) {
- if (this.config && this.config.disabledMsg) {
- this.$toast(this.config.disabledMsg)
- }
- return
- }
- const bridge = getApp().globalData.selectedValBridge
- // 主要是处理微信小程序端 uni限制 props 不能传递函数的问题
- let formBridge = {}
- if (this.isDetailTable) {
- formBridge = getApp().globalData.detailTableFields
- } else {
- formBridge = getApp().globalData.formBridge
- }
- // const formBridge = getApp().globalData.formBridge
- let request = null
- if (
- formBridge &&
- formBridge.fields &&
- formBridge.fields[this.index] &&
- formBridge.fields[this.index].sys_config
- ) {
- request = formBridge.fields[this.index].sys_config.request || null
- }
- bridge[this.type] = {
- guid: this.guid,
- title: '选择' + this.field.name,
- maxlength: 1,
- defaultVal: this.formValue || [],
- params: this.config ? (this.config.otherParams || {}) : {},
- request: request,
- config: this.config ? (this.config.optionsConfig || null) : null
- }
- // console.log('bridge: ', formBridge, bridge)
- uni.$on('selected-relevance', this.selectedRelevance)
- this.$Router.navigateTo({
- url: '/pages_common/selectList/relevance',
- query: {
- type: this.field.formType
- }
- })
- },
- selectedRelevance(data) {
- if (this.guid === data.guid) {
- this.formValue = data.data
- this.$emit('input', this.formValue)
- this.$emit('change', {
- index: this.index,
- field: this.field,
- value: this.formValue
- })
- }
- uni.$off('selected-options')
- }
- }
- }
- </script>
- <style scoped lang="scss">
- @import './wkField.scss';
- </style>
|