You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
10 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <section>
  3. <el-row>
  4. <el-form v-if="configVisible" ref="extInfosRef">
  5. <!-- 扩展字段[{name:'中文名称',id:'编号',value:'值',remark:'备注',type:'支持简单的1-普通文本2-数字,3-日期,8-富文本,9单图文,15-是否'}] -->
  6. <el-row v-for="(item, index) in extInfosList" :key="index">
  7. <el-form-item v-if="!item.type" >
  8. <el-select v-model="item.type" style="width:120px;">
  9. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  10. </el-select>
  11. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  12. <el-input style="width:10%;" v-model="item.name" placeholder="字段名称"></el-input>:
  13. <el-input v-model="item.value" placeholder="请输入数据"></el-input>
  14. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  15. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  16. </el-form-item>
  17. <el-form-item v-else-if="item.type=='1'" >
  18. <el-select v-model="item.type" style="width:120px;">
  19. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  20. </el-select>
  21. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  22. <el-input style="width:10%;" v-model="item.name" placeholder="字段名称"></el-input>:
  23. <el-input v-model="item.value" placeholder="请输入数据"></el-input>
  24. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  25. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  26. </el-form-item>
  27. <el-form-item v-else-if="item.type=='2'" >
  28. <el-select v-model="item.type" style="width:120px;">
  29. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  30. </el-select>
  31. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  32. <el-input style="width:10%;" v-model="item.name" placeholder="字段名称"></el-input>:
  33. <el-input type="number" v-model="item.value" placeholder="请输入数据"></el-input>
  34. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  35. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  36. </el-form-item>
  37. <el-form-item v-else-if="item.type=='3'" >
  38. <el-select v-model="item.type" style="width:120px;">
  39. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  40. </el-select>
  41. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  42. <el-input style="width:10%;" v-model="item.name" placeholder="字段名称"></el-input>:
  43. <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" v-model="item.value" placeholder="请输入数据"></el-date-picker>
  44. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  45. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  46. </el-form-item>
  47. <el-form-item v-else-if="item.type=='8'" >
  48. <el-select v-model="item.type" style="width:120px;">
  49. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  50. </el-select>
  51. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  52. <el-input style="width:10%;" v-model="item.name" placeholder="字段名称"></el-input>:
  53. <el-input type="textarea" rows=6 v-model="item.value" placeholder="请输入数据"></el-input>
  54. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  55. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  56. </el-form-item>
  57. <el-form-item v-else-if="item.type=='9'" >
  58. <el-select v-model="item.type" style="width:120px;">
  59. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  60. </el-select>
  61. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  62. <el-input style="width:10%;" v-model="item.name" placeholder="图片名称"></el-input>:
  63. <el-input style="width:20%;" v-model="item.value" placeholder="图片访问地址"></el-input>
  64. <el-input style="width:20%;" v-model="item.link" placeholder="跳转地址"></el-input>
  65. <el-input style="width:20%;" v-model="item.remark" placeholder="图片备注"></el-input>
  66. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  67. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  68. </el-form-item>
  69. <el-form-item v-else-if="item.type=='15'" >
  70. <el-select v-model="item.type" style="width:120px;">
  71. <el-option v-for="(it,indexx) in itemTypes" :key="indexx" :label="it.name" :value="it.id">{{it.name}} </el-option>
  72. </el-select>
  73. <el-input style="width:10%;" v-model="item.id" placeholder="字段代码(可空)"></el-input>:
  74. <el-input style="width:10%;" v-model="item.name" placeholder="字段名称"></el-input>:
  75. <el-radio v-model="item.value" :label="'1'" placeholder=""></el-radio>
  76. <el-radio v-model="item.value" :label="'0'" placeholder=""></el-radio>
  77. <el-button @click.prevent="removeExtInfosItem(item,index)" icon="el-icon-delete">
  78. </el-button><el-button @click="addExtInfosItem(item,index)" icon="el-icon-plus"></el-button>
  79. </el-form-item>
  80. </el-row>
  81. <el-form-item>
  82. <el-button @click="configVisible=false" icon="el-icon-back"><slot>返回</slot></el-button>
  83. <el-button @click="addExtInfosFirstItem" icon="el-icon-plus"><slot>新增一行</slot></el-button>
  84. </el-form-item>
  85. </el-form>
  86. <el-form v-else ref="extInfosRef" :label-width="labelWidth">
  87. <!-- 扩展字段[{name:'中文名称',id:'编号',value:'值',remark:'备注',type:'支持简单的1-普通文本2-数字,3-日期,8-富文本,9单图文,15-是否'}] -->
  88. <el-row>
  89. <el-col :span="span" v-for="(item, index) in extInfosList" :key="index">
  90. <el-form-item v-if="!item.type" :label="item.name">
  91. <el-input v-model="item.value" placeholder="请输入数据"></el-input>
  92. </el-form-item>
  93. <el-form-item v-else-if="item.type=='1'" :label="item.name">
  94. <el-input v-model="item.value" placeholder="请输入数据"></el-input>
  95. </el-form-item>
  96. <el-form-item v-else-if="item.type=='2'" :label="item.name">
  97. <el-input type="number" v-model="item.value" placeholder="请输入数据"></el-input>
  98. </el-form-item>
  99. <el-form-item v-else-if="item.type=='3'" :label="item.name">
  100. <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" v-model="item.value" placeholder="请输入数据"></el-date-picker>
  101. </el-form-item>
  102. <el-form-item v-else-if="item.type=='8'" :label="item.name">
  103. <el-input type="textarea" rows=6 v-model="item.value" placeholder="请输入数据"></el-input>
  104. </el-form-item>
  105. <el-form-item v-else-if="item.type=='9'" :label="item.name">
  106. <el-input v-model="item.value" placeholder="请输入图片地址"></el-input>
  107. </el-form-item>
  108. <el-form-item v-else-if="item.type=='15'" :label="item.name">
  109. <el-radio v-model="item.value" :label="'1'" placeholder=""></el-radio>
  110. <el-radio v-model="item.value" :label="'0'" placeholder=""></el-radio>
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. <el-form-item v-if="!cfgDisabled">
  115. <el-button @click="configVisible=true" icon="el-icon-setting"><slot>配置扩展字段</slot></el-button>
  116. </el-form-item>
  117. </el-form>
  118. </el-row>
  119. </section>
  120. </template>
  121. <script>
  122. import { mapGetters } from 'vuex'
  123. export default {
  124. name: 'MdpExtInfos',
  125. props:{
  126. value:{
  127. type:Array,
  128. default:[],
  129. },
  130. cfgDisabled:{
  131. type:Boolean,
  132. default:true,
  133. },
  134. span:{
  135. type:Number,
  136. default:24
  137. },
  138. labelWidth:{
  139. type:String,
  140. default:'120px'
  141. }
  142. },
  143. computed: {
  144. ...mapGetters([
  145. 'userInfo'
  146. ])
  147. },
  148. watch:{
  149. value(val){
  150. this.initData();
  151. },
  152. extInfosList:{
  153. deep:true,
  154. handler(val,oldVal){
  155. if(this.value instanceof Array){
  156. this.$emit("input",val)
  157. this.$emit("change",val)
  158. this.$emit("change2",val)
  159. }else{
  160. var v=JSON.stringify(val);
  161. this.$emit("input",JSON.stringify(v))
  162. this.$emit("change",v)
  163. this.$emit("change2",v)
  164. }
  165. }
  166. },
  167. },
  168. data() {
  169. return{
  170. configVisible:false,
  171. itemTypes:[//支持简单的1-普通文本2-数字,3-日期,8-富文本,9单图文,15-是否'
  172. {id:'1',name:'普通文本'},
  173. {id:'2',name:'数字'},
  174. {id:'3',name:'日期'},
  175. {id:'8',name:'富文本'},
  176. {id:'9',name:'单图文'},
  177. {id:'15',name:'是否'}
  178. ],
  179. extInfosList:[],//[{name:'中文名称',id:'编号',value:'值',link:'超链接',remark:'备注',type:'支持简单的1-普通文本2-数字,3-日期,8-富文本,9单图文,15-是否'}]
  180. }
  181. },//end data
  182. methods: {
  183. addExtInfosFirstItem(){
  184. if(!this.extInfosList){
  185. this.extInfosList=[]
  186. }
  187. this.extInfosList.push({id:'',name:'字段名'+this.extInfosList.length+'(请修改)',value:'',url:'',extInfo:'',type:'1',remark:''})
  188. },
  189. addExtInfosItem(item,index){
  190. this.extInfosList.splice(index+1,0,{id:'',name:'字段名'+(index+1)+'(请修改)',value:'',url:'',extInfo:'',type:'1',remark:''})
  191. },
  192. removeExtInfosItem(item,index){
  193. this.extInfosList.splice(index,1)
  194. },
  195. initData(){
  196. debugger;
  197. if(this.value){
  198. if(this.value instanceof Array){
  199. this.extInfosList=this.value
  200. }else{
  201. this.extInfosList=JSON.parse(this.value)
  202. }
  203. }else{
  204. this.extInfosList=[]
  205. }
  206. }
  207. },//end methods
  208. components: {
  209. },
  210. mounted() {
  211. this.initData();
  212. }
  213. }
  214. </script>
  215. <style scoped>
  216. </style>