chunk-f446.56babded.js 12 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-f446"],{BZE7:function(t,e,i){},MKJu:function(t,e,i){"use strict";var a=i("BZE7");i.n(a).a},oX5y:function(t,e,i){"use strict";i.r(e);var a=i("P2sY"),r=i.n(a),o=i("xAVR"),l=i("rs3x"),n=i("X4fA"),s=i("7Qib"),c=[{text:"一级类目",value:0},{text:"二级类目",value:1},{text:"三级类目",value:2}],d={name:"Category",components:{Pagination:i("Mz3J").a},filters:{categoryLevelFilter:function(t){return t>=0&&t<3?c[t].text:"错误级别"}},data:function(){return{options:[],uploadPath:l.b,list:void 0,total:0,listLoading:!0,dialogOptions:void 0,queryOptions:void 0,listQuery:{pageNo:1,limit:20,id:void 0,title:void 0,level:void 0,parentId:void 0},catL1:{},dataForm:{id:void 0,title:void 0,level:void 0,parentId:void 0,iconUrl:void 0,picUrl:void 0},dialogFormVisible:!1,dialogStatus:"",textMap:{update:"编辑",create:"创建"},rules:{title:[{required:!0,message:"类目名不能为空",trigger:"blur"}]},downloadLoading:!1,categoryLevelMap:c}},computed:{headers:function(){return{accessToken:Object(n.a)()}}},created:function(){this.getList(),this.refreshOptions()},methods:{tlog:function(t){console.log(t)},getList:function(){var t=this;this.listLoading=!0,Object(o.e)(this.listQuery).then(function(e){t.list=e.data.data.items,t.total=e.data.data.total,t.listLoading=!1}).catch(function(){t.list=[],t.total=0,t.listLoading=!1})},handleFilter:function(){if(this.listQuery.pageNo=1,null!=this.listQuery.id&&isNaN(Number(this.listQuery.id)))return this.$notify.error({title:"失败",message:"请输入整数"}),!1;this.getList()},resetForm:function(){this.dataForm={id:void 0,title:void 0,level:void 0,parentId:0,iconUrl:void 0,picUrl:void 0}},resetQuery:function(){this.listQuery={pageNo:1,limit:20,id:void 0,title:void 0,level:void 0,parentId:void 0}},handleCreate:function(){var t=this;this.resetForm(),this.dialogStatus="create",this.dialogOptions=void 0,this.queryOptions=void 0,this.resetQuery(),this.refreshOptions(),this.dialogFormVisible=!0,this.$nextTick(function(){t.$refs.dataForm.clearValidate()})},createData:function(){var t=this;this.$refs.dataForm.validate(function(e){Object(o.c)(t.dataForm).then(function(e){t.resetQuery(),t.listQuery.title=t.dataForm.title,t.getList(),t.dialogFormVisible=!1,t.$notify.success({title:"成功",message:"创建成功"}),t.refreshOptions()}).catch(function(e){t.$notify.error({title:"失败",message:e.data.errmsg})})})},handleUpdate:function(t){var e=this;this.dataForm=r()({},{id:t.value,title:t.label,parentId:t.parent,picUrl:t.picUrl,iconUrl:t.iconUrl}),this.dialogOptions=t.parent,this.refreshOptions(),this.dialogStatus="update",this.dialogFormVisible=!0,this.$nextTick(function(){e.$refs.dataForm.clearValidate()})},updateData:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&Object(o.f)(t.dataForm).then(function(){t.getList(),t.dialogFormVisible=!1,t.$notify.success({title:"成功",message:"更新成功"}),t.refreshOptions()}).catch(function(e){t.$notify.error({title:"失败",message:e.data.errmsg})})})},handleDelete:function(t){var e=this;this.$confirm("此操作将永久删除该类目--"+t.label+"--, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){Object(o.d)(t.value).then(function(i){e.$notify.success({title:"成功",message:"删除成功"});var a=e.list.indexOf(t);e.list.splice(a,1),e.refreshOptions()}).catch(function(t){e.$notify.error({title:"失败",message:t.data.errmsg})})}).catch(function(){return!1})},onBeforeUpload:function(t){var e="image/jpeg"===t.type||"image/gif",i=t.size/1024/1024<1;return e||this.$message.error("上传文件只能是图片格式!"),i||this.$message.error("上传文件大小不能超过 1MB!"),e&&i},iconUploadSuccessHandle:function(t){this.dataForm.iconUrl=t.url,this.dialogFormVisible=!1,this.dialogFormVisible=!0},pirUploadSuccessHandle:function(t){this.dataForm.picUrl=t.url,this.dialogFormVisible=!1,this.dialogFormVisible=!0},handleLink:function(t){if(null==t||void 0===t)return!1;var e=t[t.length-1];"update"===this.dialogStatus&&this.dataForm.id===e&&this.$notify.error({title:"失败",message:"请不要选择本节点作为父节点"}),this.dataForm.parentId=e},handleQuery:function(t){if(null==t||void 0===t)return!1;this.refreshOptions();var e=t[t.length-1];this.listQuery.parentId=e},refreshOptions:function(){var t=this;Object(o.a)().then(function(e){t.options=Object(s.a)(e.data.data)})}}},u=(i("MKJu"),i("KHd+")),p=Object(u.a)(d,function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"app-container"},[i("div",{staticClass:"filter-container"},[i("el-input",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"请输入类目ID"},model:{value:t.listQuery.id,callback:function(e){t.$set(t.listQuery,"id",e)},expression:"listQuery.id"}}),t._v(" "),i("el-input",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"请输入类目名称"},model:{value:t.listQuery.title,callback:function(e){t.$set(t.listQuery,"title",e)},expression:"listQuery.title"}}),t._v(" "),i("el-select",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"请选择类目级别"},model:{value:t.listQuery.level,callback:function(e){t.$set(t.listQuery,"level",e)},expression:"listQuery.level"}},t._l(t.categoryLevelMap,function(t,e){return i("el-option",{key:e,attrs:{label:t.text,value:t.value}})})),t._v(" "),i("el-cascader",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{options:t.options,props:{checkStrictly:!0},placeholder:"请选择父类目",filterable:"",clearable:""},on:{change:t.handleQuery},model:{value:t.queryOptions,callback:function(e){t.queryOptions=e},expression:"queryOptions"}}),t._v(" "),i("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["operation:category:query"],expression:"['operation:category:query']"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-search"},on:{click:t.handleFilter}},[t._v("查找")]),t._v(" "),i("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["operation:category:create"],expression:"['operation:category:create']"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-edit"},on:{click:t.handleCreate}},[t._v("添加")])],1),t._v(" "),i("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],attrs:{data:t.list,size:"small","element-loading-text":"正在查询中。。。",border:"",fit:"","highlight-current-row":""}},[i("el-table-column",{attrs:{align:"center",label:"类目ID",prop:"value"}}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"类目名",prop:"label"},scopedSlots:t._u([{key:"default",fn:function(e){return[i("el-tag",[t._v(t._s(e.row.label))])]}}])}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"全类目名",prop:"fullName"},scopedSlots:t._u([{key:"default",fn:function(e){return[i("el-tag",[t._v(t._s(e.row.fullName))])]}}])}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"父类目ID",prop:"parent"}}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"级别",prop:"level"},scopedSlots:t._u([{key:"default",fn:function(e){return[i("el-tag",[t._v(t._s(t._f("categoryLevelFilter")(e.row.level)))])]}}])}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"标志图片",prop:"iconUrl"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.iconUrl?i("img",{attrs:{src:e.row.iconUrl,width:"80"}}):t._e()]}}])}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"类目图片",prop:"picUrl"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.picUrl?i("img",{attrs:{src:e.row.picUrl,width:"80"}}):t._e()]}}])}),t._v(" "),i("el-table-column",{attrs:{align:"center",label:"操作",width:"200","class-name":"small-padding fixed-width"},scopedSlots:t._u([{key:"default",fn:function(e){return[i("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["operation:category:update"],expression:"['operation:category:update']"}],attrs:{type:"primary",size:"mini"},on:{click:function(i){t.handleUpdate(e.row)}}},[t._v("编辑")]),t._v(" "),i("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["operation:category:delete"],expression:"['operation:category:delete']"}],attrs:{type:"danger",size:"mini"},on:{click:function(i){t.handleDelete(e.row)}}},[t._v("删除")])]}}])})],1),t._v(" "),i("pagination",{directives:[{name:"show",rawName:"v-show",value:t.total>0,expression:"total>0"}],attrs:{total:t.total,page:t.listQuery.pageNo,limit:t.listQuery.limit},on:{"update:page":function(e){t.$set(t.listQuery,"pageNo",e)},"update:limit":function(e){t.$set(t.listQuery,"limit",e)},pagination:t.getList}}),t._v(" "),i("el-dialog",{attrs:{title:t.textMap[t.dialogStatus],visible:t.dialogFormVisible},on:{"update:visible":function(e){t.dialogFormVisible=e}}},[i("el-form",{ref:"dataForm",staticStyle:{width:"400px","margin-left":"50px"},attrs:{rules:t.rules,model:t.dataForm,"status-icon":"","label-position":"left","label-width":"100px"}},[i("el-form-item",{attrs:{label:"类目ID",prop:"id",hidden:""}},[i("el-input",{model:{value:t.dataForm.id,callback:function(e){t.$set(t.dataForm,"id",e)},expression:"dataForm.id"}})],1),t._v(" "),i("el-form-item",{attrs:{label:"类目名称",prop:"title"}},[i("el-input",{on:{input:t.tlog},model:{value:t.dataForm.title,callback:function(e){t.$set(t.dataForm,"title",e)},expression:"dataForm.title"}})],1),t._v(" "),i("el-form-item",{attrs:{label:"类目图片",prop:"picUrl"}},[i("el-upload",{staticClass:"avatar-uploader",attrs:{headers:t.headers,action:t.uploadPath,"show-file-list":!1,"on-success":t.pirUploadSuccessHandle,"before-upload":t.onBeforeUpload,accept:".jpg, .jpeg, .png, .gif"}},[t.dataForm.picUrl?i("img",{ref:"adImg",staticClass:"avatar",attrs:{src:t.dataForm.picUrl}}):i("i",{staticClass:"el-icon-plus avatar-uploader-icon"})])],1),t._v(" "),i("el-form-item",{attrs:{label:"父类目"}},[i("el-cascader",{attrs:{options:t.options,props:{checkStrictly:!0},placeholder:"选择父类目,默认一级类目",filterable:"",clearable:""},on:{change:t.handleLink},model:{value:t.dialogOptions,callback:function(e){t.dialogOptions=e},expression:"dialogOptions"}})],1)],1),t._v(" "),i("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{on:{click:function(e){t.dialogFormVisible=!1}}},[t._v("取消")]),t._v(" "),"create"==t.dialogStatus?i("el-button",{attrs:{type:"primary"},on:{click:t.createData}},[t._v("确定")]):i("el-button",{attrs:{type:"primary"},on:{click:t.updateData}},[t._v("确定")])],1)],1)],1)},[],!1,null,null,null);p.options.__file="category.vue";e.default=p.exports},rs3x:function(t,e,i){"use strict";i.d(e,"b",function(){return r}),i.d(e,"a",function(){return o});var a=i("t3Un"),r="https://api.diy-factoies.com/upload/admin";function o(t){return Object(a.a)({url:r,method:"post",data:t})}},xAVR:function(t,e,i){"use strict";i.d(e,"a",function(){return s}),i.d(e,"b",function(){return c}),i.d(e,"e",function(){return d}),i.d(e,"c",function(){return u}),i.d(e,"f",function(){return p}),i.d(e,"d",function(){return m});var a=i("QbLZ"),r=i.n(a),o=i("t3Un"),l=i("Qyje"),n=i.n(l);function s(){return Object(o.a)({method:"get",params:{_gp:"admin.category",_mt:"categorySecondLevelTree"}})}function c(){return Object(o.a)({method:"get",params:{_gp:"admin.category",_mt:"categoryTree"}})}function d(t){return Object(o.a)({method:"get",params:r()({_gp:"admin.category",_mt:"queryCategory"},t)})}function u(t){return Object(o.a)({method:"post",data:n.a.stringify(r()({_gp:"admin.category",_mt:"addCategory"},t))})}function p(t){return Object(o.a)({method:"post",data:n.a.stringify(r()({_gp:"admin.category",_mt:"updateCategory"},t))})}function m(t){return Object(o.a)({method:"post",params:{_gp:"admin.category",_mt:"deleteCategory",id:t}})}}}]);