(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0e28b6"],{"7ec5":function(e,t,l){"use strict";l.r(t);var i=function(){var e=this,t=e.$createElement,l=e._self._c||t;return l("div",{staticClass:"app-container"},[l("el-row",{staticClass:"mb8",attrs:{gutter:10}},[l("el-col",{attrs:{span:1.5}},[l("el-button",{attrs:{type:"primary",icon:"el-icon-plus",size:"mini"},on:{click:e.handleAdd}},[e._v("新增")])],1),e._v(" "),l("el-col",{attrs:{span:1.5}},[l("el-button",{attrs:{type:"success",icon:"el-icon-edit",size:"mini",disabled:e.single},on:{click:e.handleUpdate}},[e._v("修改")])],1),e._v(" "),l("el-col",{attrs:{span:1.5}},[l("el-button",{attrs:{type:"danger",icon:"el-icon-delete",size:"mini",disabled:e.multiple},on:{click:e.handleDelete}},[e._v("删除")])],1)],1),e._v(" "),l("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],ref:"dragTable",attrs:{data:e.fieldsList,"row-key":"field_id"},on:{"selection-change":e.handleSelectionChange}},[l("el-table-column",{attrs:{align:"center",width:"40"},scopedSlots:e._u([{key:"default",fn:function(e){return[l("svg-icon",{staticClass:"drag-handler",attrs:{"icon-class":"drag"}})]}}])}),e._v(" "),l("el-table-column",{attrs:{type:"selection",width:"45",align:"center"}}),e._v(" "),l("el-table-column",{attrs:{label:"字段编号",align:"center",width:"50",prop:"field_id"}}),e._v(" "),l("el-table-column",{attrs:{label:"字段名称",align:"center",prop:"field_name"}}),e._v(" "),l("el-table-column",{attrs:{label:"字段标题",align:"center",prop:"field_title"}}),e._v(" "),l("el-table-column",{attrs:{label:"字段类型",align:"center",prop:"field_type"}}),e._v(" "),l("el-table-column",{attrs:{label:"字段规则",align:"center",prop:"field_rules"}}),e._v(" "),l("el-table-column",{attrs:{label:"主键","min-width":"30"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-radio",{attrs:{label:t.row.field_id},model:{value:e.fieldPkId,callback:function(t){e.fieldPkId=t},expression:"fieldPkId"}},[e._v("是")])]}}])}),e._v(" "),l("el-table-column",{attrs:{label:"排序字段","min-width":"30"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-checkbox",{attrs:{"true-label":"1"},model:{value:t.row.model_sort,callback:function(l){e.$set(t.row,"model_sort",l)},expression:"scope.row.model_sort"}})]}}])}),e._v(" "),l("el-table-column",{attrs:{label:"列表显示","min-width":"30"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-checkbox",{attrs:{"true-label":"1"},model:{value:t.row.model_list,callback:function(l){e.$set(t.row,"model_list",l)},expression:"scope.row.model_list"}})]}}])}),e._v(" "),l("el-table-column",{attrs:{label:"可编辑","min-width":"30"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-checkbox",{attrs:{"true-label":"1"},model:{value:t.row.model_edit,callback:function(l){e.$set(t.row,"model_edit",l)},expression:"scope.row.model_edit"}})]}}])}),e._v(" "),l("el-table-column",{attrs:{label:"模型索引","min-width":"30"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-checkbox",{attrs:{"true-label":"1"},model:{value:t.row.model_indexes,callback:function(l){e.$set(t.row,"model_indexes",l)},expression:"scope.row.model_indexes"}})]}}])}),e._v(" "),l("el-table-column",{attrs:{label:"列表查询","min-width":"30"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-checkbox",{attrs:{"true-label":"1"},model:{value:t.row.search_list,callback:function(l){e.$set(t.row,"search_list",l)},expression:"scope.row.search_list"}})]}}])}),e._v(" "),l("el-table-column",{attrs:{label:"操作",align:"center","class-name":"small-padding fixed-width"},scopedSlots:e._u([{key:"default",fn:function(t){return[l("el-button",{attrs:{size:"mini",type:"text",icon:"el-icon-edit"},on:{click:function(l){return e.handleUpdate(t.row)}}},[e._v("修改")]),e._v(" "),l("el-button",{attrs:{size:"mini",type:"text",icon:"el-icon-delete"},on:{click:function(l){return e.handleDelete(t.row)}}},[e._v("删除")])]}}])})],1),e._v(" "),l("el-form",{attrs:{"label-width":"100px"}},[l("el-form-item",{staticStyle:{"text-align":"center","margin-left":"-100px","margin-top":"10px"}},[l("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.submitFormList()}}},[e._v("提交")]),e._v(" "),l("el-button",{on:{click:function(t){return e.close()}}},[e._v("返回")])],1)],1),e._v(" "),l("el-dialog",{attrs:{title:e.title,visible:e.open,width:"600px","append-to-body":""},on:{"update:visible":function(t){e.open=t}}},[l("el-form",{ref:"form",attrs:{model:e.form,rules:e.rules,"label-width":"160px"}},[l("el-form-item",{attrs:{label:"字段名称",prop:"fieldName"}},[l("el-input",{attrs:{placeholder:"请输入字段名称"},model:{value:e.form.fieldName,callback:function(t){e.$set(e.form,"fieldName",t)},expression:"form.fieldName"}})],1),e._v(" "),l("el-form-item",{attrs:{label:"字段标题",prop:"fieldTitle"}},[l("el-input",{attrs:{placeholder:"请输入字段标题"},model:{value:e.form.fieldTitle,callback:function(t){e.$set(e.form,"fieldTitle",t)},expression:"form.fieldTitle"}})],1),e._v(" "),l("el-form-item",{attrs:{label:"字段类型",prop:"fieldType"}},[l("el-select",{on:{change:e.typeChange},model:{value:e.form.fieldType,callback:function(t){e.$set(e.form,"fieldType",t)},expression:"form.fieldType"}},e._l(e.fieldsType,(function(e){return l("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),e._v(" "),l("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.tagShow.inputData,expression:"tagShow.inputData"}],attrs:{prop:"fieldData"}},[l("span",{attrs:{slot:"label"},slot:"label"},[e._v("\n 字段数据\n "),l("el-tooltip",{attrs:{content:"格式:'1:text1,2:text2,3:text3' 或 '数据表名|值字段名|标题字段名(|排序字段)(|条件)' 或 :字典编码",placement:"top-start"}},[l("i",{staticClass:"el-icon-question"})])],1),e._v(" "),l("el-input",{attrs:{placeholder:"请输入字段数据"},model:{value:e.form.fieldData,callback:function(t){e.$set(e.form,"fieldData",t)},expression:"form.fieldData"}})],1),e._v(" "),l("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.tagShow.inputLength,expression:"tagShow.inputLength"}],attrs:{label:"字段长度",prop:"fieldLength"}},[l("el-input",{attrs:{placeholder:"请输入字段长度"},model:{value:e.form.fieldLength,callback:function(t){e.$set(e.form,"fieldLength",t)},expression:"form.fieldLength"}})],1),e._v(" "),l("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.tagShow.inputDefault,expression:"tagShow.inputDefault"}],attrs:{label:"字段默认值",prop:"fieldDefault"}},[l("el-input",{attrs:{placeholder:"请输入字段默认值 地图类型时'lng,lat'"},model:{value:e.form.fieldDefault,callback:function(t){e.$set(e.form,"fieldDefault",t)},expression:"form.fieldDefault"}})],1),e._v(" "),l("el-form-item",{attrs:{label:"字段说明",prop:"fieldDesc"}},[l("el-input",{attrs:{placeholder:"请输入字段说明"},model:{value:e.form.fieldDesc,callback:function(t){e.$set(e.form,"fieldDesc",t)},expression:"form.fieldDesc"}})],1),e._v(" "),l("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.tagShow.inputRules,expression:"tagShow.inputRules"}],attrs:{label:"字段规则",prop:"fieldRules"}},[l("el-select",{attrs:{multiple:""},model:{value:e.form.fieldRules,callback:function(t){e.$set(e.form,"fieldRules",t)},expression:"form.fieldRules"}},e._l(e.fieldsRules,(function(e){return l("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),e._v(" "),l("el-form-item",{attrs:{label:"字段列表显示宽度",prop:"fieldWidth"}},[l("el-input",{attrs:{placeholder:"请输入字段列表显示宽度"},model:{value:e.form.fieldWidth,callback:function(t){e.$set(e.form,"fieldWidth",t)},expression:"form.fieldWidth"}})],1),e._v(" "),l("el-form-item",{attrs:{label:"字段列表对齐方式",prop:"fieldAlign"}},[l("el-input",{attrs:{placeholder:"请输入字段列表对齐方式"},model:{value:e.form.fieldAlign,callback:function(t){e.$set(e.form,"fieldAlign",t)},expression:"form.fieldAlign"}})],1)],1),e._v(" "),l("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[l("el-button",{attrs:{type:"primary"},on:{click:e.submitForm}},[e._v("确 定")]),e._v(" "),l("el-button",{on:{click:e.cancel}},[e._v("取 消")])],1)],1)],1)},a=[],o=(l("28a5"),l("6762"),l("2fdb"),l("b775"));function n(e){return Object(o["a"])({url:"/system/model/fields/add",method:"post",data:e})}function s(e){return Object(o["a"])({url:"/system/model/fields/list",method:"get",params:{modelId:e}})}function r(e,t,l){return Object(o["a"])({url:"/system/model/fields/setFieldsAttr",method:"post",data:{fieldsList:e,pkId:t,modelId:l}})}function d(e){return Object(o["a"])({url:"/system/model/fields/edit?id="+e,method:"get"})}function u(e){return Object(o["a"])({url:"/system/model/fields/edit",method:"post",data:e})}function c(e){return Object(o["a"])({url:"/system/model/fields/delete",method:"delete",data:{ids:e}})}var f=l("53fe"),m=l.n(f),p={name:"Post",data:function(){return{loading:!0,ids:[],fieldPkId:null,single:!0,multiple:!0,fieldsList:[],oldList:[],newList:[],title:"",open:!1,statusOptions:[],fieldsType:[{value:"text",label:"文本"},{value:"baidu_map",label:"百度地图坐标"},{value:"imagefile",label:"单图片"},{value:"images",label:"多图片"},{value:"file",label:"单文件"},{value:"files",label:"多文件"},{value:"selecttext",label:"选择文本"},{value:"currency",label:"货币"},{value:"large_number",label:"长整型"},{value:"number",label:"整数"},{value:"datetime",label:"日期时间"},{value:"date",label:"日期"},{value:"selectnumber",label:"选择数字"},{value:"richtext",label:"富文本"},{value:"bigtext",label:"文本域"},{value:"switch",label:"开关"},{value:"checkbox",label:"多选框"},{value:"DepartmentSelector",label:"部门选择器"}],fieldsRules:[{value:"lengthfixed",label:"lengthfixed"},{value:"required",label:"required"},{value:"unsigned",label:"unsigned"},{value:"unique",label:"unique"},{value:"readonly",label:"readonly"},{value:"hidden",label:"hidden"}],dataSelect:["selecttext","checkbox","selectnumber"],tagShow:{inputData:!1,inputLength:!1,inputDefault:!1,inputRules:!0},modelId:0,form:{},rules:{fieldName:[{required:!0,message:"字段名称不能为空",trigger:"blur"}],fieldTitle:[{required:!0,message:"字段标题不能为空",trigger:"blur"}],fieldType:[{required:!0,message:"字段类型不能为空",trigger:"change"}]}}},created:function(){var e=this.$route.query.modelId;e&&(this.modelId=e),this.getList()},methods:{getList:function(){var e=this;this.loading=!0,s(this.modelId).then((function(t){e.fieldsList=t.data.list?t.data.list:[],e.oldList=e.fieldsList.map((function(t){return"1"==t.model_pk&&(e.fieldPkId=t.field_id),t.field_id})),e.newList=e.oldList.slice(),e.loading=!1,e.$nextTick((function(){e.setSort()}))}))},typeChange:function(e){this.showOption(e)},showOption:function(e){this.dataSelect.includes(e)?(this.tagShow.inputData=!0,this.tagShow.inputLength=!1):"text"==e?(this.tagShow.inputData=!1,this.tagShow.inputLength=!0):(this.tagShow.inputData=!1,this.tagShow.inputLength=!1),this.tagShow.inputDefault="imagefile"!=e&&"images"!=e&&"file"!=e&&"files"!=e,this.tagShow.inputRules="switch"!=e},cancel:function(){this.open=!1,this.reset()},reset:function(){this.form={fieldId:void 0,modelId:this.modelId,fieldName:void 0,fieldTitle:void 0,fieldType:"",fieldData:void 0,fieldLength:void 0,fieldDefault:void 0,fieldDesc:void 0,fieldRules:[],fieldWidth:"",fieldAlign:""},this.resetForm("form")},handleQuery:function(){this.getList()},resetQuery:function(){this.resetForm("queryForm"),this.handleQuery()},handleSelectionChange:function(e){this.ids=e.map((function(e){return e.field_id})),this.single=1!=e.length,this.multiple=!e.length},handleAdd:function(){this.reset(),this.open=!0,this.title="添加字段"},handleUpdate:function(e){var t=this;this.reset();var l=e.field_id||this.ids;d(l).then((function(e){var l=e.data;l&&(t.form={fieldId:l.field_id,modelId:l.model_id,fieldName:l.field_name,fieldTitle:l.field_title,fieldType:l.field_type,fieldData:l.field_data,fieldLength:l.field_length,fieldDefault:l.field_default,fieldDesc:l.field_desc,fieldRules:""!=l.field_rules?l.field_rules.split(","):[],fieldWidth:l.field_width,fieldAlign:l.field_align},t.showOption(t.form.fieldType)),t.open=!0,t.title="修改字段"}))},submitForm:function(){var e=this;this.$refs["form"].validate((function(t){t&&(void 0!=e.form.fieldId?u(e.form).then((function(t){0===t.code?(e.msgSuccess("修改成功"),e.open=!1,e.getList()):e.msgError(t.msg)})):n(e.form).then((function(t){0===t.code?(e.msgSuccess("新增成功"),e.open=!1,e.getList()):e.msgError(t.msg)})))}))},submitFormList:function(){var e=this;r(this.fieldsList,this.fieldPkId,this.modelId).then((function(t){0===t.code?(e.msgSuccess("修改成功"),e.getList()):e.msgError(t.msg)}))},handleDelete:function(e){var t=this,l=e.field_id?[e.field_id]:this.ids;this.$confirm('是否确认删除字段编号为"'+l+'"的数据项?',"警告",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){return c(l)})).then((function(){t.getList(),t.msgSuccess("删除成功")})).catch((function(){}))},setSort:function(){var e=this,t=this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0];this.sortable=m.a.create(t,{ghostClass:"sortable-ghost",setData:function(e){e.setData("Text","")},onEnd:function(t){var l=e.fieldsList.splice(t.oldIndex,1)[0];e.fieldsList.splice(t.newIndex,0,l);var i=e.newList.splice(t.oldIndex,1)[0];e.newList.splice(t.newIndex,0,i)}})},close:function(){this.$store.dispatch("tagsView/delView",this.$route),this.$router.push({path:"/model/list",query:{t:Date.now()}})}}},h=p,b=l("2877"),v=Object(b["a"])(h,i,a,!1,null,null,null);t["default"]=v.exports}}]);
-
由 huaxinzhu 提交于8b7bdead