123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <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'"></view>
- <view v-else-if="(item.field === 'labelId') || (item.field === 'createTime')">
- <view v-if="form[item.field]" 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>
- <input
- v-if="item.type === 'input'" :value="form[item.field]" class="input" disabled
- type="text"
- :placeholder="item.placeholder"
- />
- </view>
- </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="item.field === 'enterpriseUserId'" :type="item.field === 'enterpriseUserId' ? 'number' : 'text'"
- :placeholder="item.placeholder" @input="handleInput(item.field, $event)"
- />
- </view>
- </template>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'FieldPaneCLF',
- props: {
- fields: {
- type: Array,
- required: true
- },
- value: {
- type: Object,
- required: true
- },
- title: String
- },
- data() {
- return {
- form: {}
- }
- },
- watch: {
- fields: {
- handler(value) {
- if (value) {
- const form = {}
- for (const item of value) {
- form[item.field] = this.value[item.field]
- }
- this.form = form
- }
- },
- immediate: true,
- deep: true
- },
- form: {
- handler(value) {
- this.$emit('input', value)
- },
- immediate: true,
- deep: true
- }
- },
- created() {
- },
- mounted() {
- // console.log(this.$refs)
- },
- methods: {
- handleInput(field, e) {
- console.log(field, e)
- if (field === 'labelName') {
- 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>
|