123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="field-pane-container">
- <view class="title">{{ title }}</view>
- <view v-for="item in fields" :key="item.label">
- <view
- v-if="(item.field === 'id') || (item.field === 'label') || (item.field === 'enterpriseUserId') || (item.field === 'buyerId')"
- >
- </view>
- <view v-else-if="item.field === 'birthday'">
- <view class="item">
- <template>
- <view
- class="input-wrapper" :style="{
- 'flex-direction': item.type === 'textarea' ? 'column' : '',
- 'align-items': item.type === 'textarea' ? 'flex-start' : ''
- }"
- >
- <view class="sub-title">{{ item.label }}</view>
- <view v-if="item.type === 'time' && item.field === 'birthday'" class="input">
- <input
- :value="form[item.field]" :disabled="true" type="text"
- :placeholder="item.placeholder"
- @click="$refs.dateTimeTradeB[0].show()"
- />
- <tui-datetime
- ref="dateTimeTradeB" :type="2" radius
- @confirm="handleInput(item.field, $event)"
- ></tui-datetime>
- </view>
- </view>
- </template>
- </view>
- </view>
- <view v-else-if="item.field === 'styleId'">
- <view class="item">
- <view
- class="input-wrapper" :style="{
- 'flex-direction': item.type === 'textarea' ? 'column' : '',
- 'align-items': item.type === 'textarea' ? 'flex-start' : ''
- }"
- >
- <view class="sub-title">{{ item.label }}</view>
- <view
- v-if="item.type === 'select' && item.field === 'styleId'" style="flex: 1" :style="{
- color: form.styleId ? '' : '#999'
- }" @click="isShowStyleListSelect = true"
- >
- {{ styleName || (form.styleId ? `已选样式:${form.styleId}` : "请选择样式") }}
- </view>
- </view>
- </view>
- </view>
- <view
- v-else-if="(item.field === 'enterpriseName') || (item.field === 'enterpriseDuties') || (item.field === 'enterpriseDepartment')"
- >
- <view v-if="form.isEnterprise === 'true'">
- <view class="item">
- <template>
- <view
- class="input-wrapper" :style="{
- 'flex-direction': item.type === 'textarea' ? 'column' : '',
- 'align-items': item.type === 'textarea' ? 'flex-start' : ''
- }"
- >
- <view class="sub-title">{{ item.label }}</view>
- <input
- v-if="item.type === 'input'" :value="form[item.field]" class="input" :disabled="false"
- :type="item.field === 'phone' ? 'number' : 'text'" :placeholder="item.placeholder"
- @input="handleInput(item.field, $event)"
- />
- </view>
- </template>
- </view>
- </view>
- <view v-else></view>
- </view>
- <view v-else class="item">
- <template>
- <view
- class="input-wrapper" :style="{
- 'flex-direction': item.type === 'textarea' ? 'column' : '',
- 'align-items': item.type === 'textarea' ? 'flex-start' : ''
- }"
- >
- <view class="sub-title">{{ item.label }}</view>
- <input
- v-if="item.type === 'input'" :value="form[item.field]" class="input" :disabled="false"
- :type="item.field === 'phone' ? 'number' : 'text'" :placeholder="item.placeholder"
- @input="handleInput(item.field, $event)"
- />
- <textarea
- v-if="item.type === 'textarea'" :value="form[item.field]" class="textarea"
- :placeholder="item.placeholder" @input="handleInput(item.field, $event)"
- ></textarea>
- <tui-radio-group
- v-if="(item.type === 'radio') && (item.field === 'sex')" v-model="form[item.field]"
- @change="handleInput(item.field, $event)"
- >
- <view style="display: flex;">
- <tui-label v-for="(part, index) in [{ name: '男', value: '1' }, { name: '女', value: '2' }]" :key="index">
- <tui-list-cell padding="16rpx">
- <view>
- <tui-radio :checked="false" :value="part.value" color="#07c160" border-color="#999">
- </tui-radio>
- <text>{{ part.name }}</text>
- </view>
- </tui-list-cell>
- </tui-label>
- </view>
- </tui-radio-group>
- <tui-radio-group
- v-else-if="item.type === 'radio'" v-model="form[item.field]" style="display: flex;"
- @change="(e) => { }"
- >
- <view style="display: flex;">
- <tui-label v-for="(part, index) in [{ name: '是', value: 'true' }, { name: '否', value: 'false' }]" :key="index">
- <tui-list-cell padding="16rpx">
- <view>
- <tui-radio :checked="false" :value="part.value" color="#07c160" border-color="#999">
- </tui-radio>
- <text>{{ part.name }}</text>
- </view>
- </tui-list-cell>
- </tui-label>
- </view>
- </tui-radio-group>
- </view>
- </template>
- </view>
- </view>
- <!-- 样式 -->
- <tui-select
- :list="styleList" reverse :show="isShowStyleListSelect" @confirm="handleSelectStyleList"
- @close="isShowStyleListSelect = false"
- ></tui-select>
- </view>
- </template>
- <script>
- export default {
- name: 'FieldPaneCCF',
- props: {
- fields: {
- type: Array,
- required: true
- },
- value: {
- type: Object,
- required: true
- },
- title: String
- },
- data() {
- return {
- form: {},
- styleList: [],
- isShowStyleListSelect: false,
- styleName: ''
- }
- },
- watch: {
- fields: {
- handler(value) {
- if (value) {
- const form = {}
- for (const item of value) {
- form[item.field] = this.value[item.field]
- if (item.type === 'select' && item.field === 'styleId') this.getStyleList()
- }
- this.form = form
- }
- },
- immediate: true,
- deep: true
- },
- form: {
- handler(value) {
- this.$emit('input', value)
- },
- immediate: true,
- deep: true
- }
- },
- methods: {
- getStyleList() {
- // getxxxApi({})
- // .then((res) => {
- this.styleList = [{ styleId: 1, value: 1, text: '样式一' }, { styleId: 2, value: 2, text: '样式二' }, { styleId: 3, value: 3, text: '样式三' }]
- // })
- // .catch(() => {
- // this.$showToast('样式列表获取失败')
- // })
- },
- handleSelectStyleList(e) {
- this.isShowStyleListSelect = false
- this.styleName = e.options.text
- this.form.styleId = e.options.styleId
- },
- handleInput(field, e) {
- console.log(field, e)
- if (field === 'birthday') {
- this.form[field] = e.result
- } else {
- this.form[field] = e.detail.value
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .field-pane-container {
- margin-top: 30rpx;
- .title {
- font-size: 28rpx;
- color: #fa5151;
- font-weight: bold;
- }
- .item {
- padding: 20rpx 0;
- border-bottom: 1rpx solid #d8d8d8;
- margin-top: 20rpx;
- .input-wrapper {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 24rpx;
- color: #3d3d3d;
- .sub-title {
- margin-right: 20rpx;
- }
- /deep/ .uni-input-placeholder,
- /deep/ .uni-textarea-placeholder {
- font-size: 24rpx;
- color: #999;
- }
- .input {
- flex: 1;
- font-size: 24rpx;
- }
- .textarea {
- margin-top: 20rpx;
- width: 100%;
- height: 100px;
- font-size: 24rpx;
- }
- }
- }
- }
- </style>
|