2025-04-01 09:03:51 +08:00

1 line
16 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

require('../common/vendor.js');(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["packageA/my/addManagement"],{"0a1a":function(t,e,s){"use strict";(function(t,e){var i=s("47a9");s("5e3a");i(s("3240"));var a=i(s("7c16"));t.__webpack_require_UNI_MP_PLUGIN__=s,e(a.default)}).call(this,s("3223")["default"],s("df3c")["createPage"])},"26dc":function(t,e,s){},"2f33":function(t,e,s){"use strict";s.r(e);var i=s("9fff"),a=s.n(i);for(var o in i)["default"].indexOf(o)<0&&function(t){s.d(e,t,(function(){return i[t]}))}(o);e["default"]=a.a},4683:function(t,e,s){"use strict";s.d(e,"b",(function(){return a})),s.d(e,"c",(function(){return o})),s.d(e,"a",(function(){return i}));var i={zxzUniDataSelect:function(){return Promise.all([s.e("common/vendor"),s.e("uni_modules/zxz-uni-data-select/components/zxz-uni-data-select/zxz-uni-data-select")]).then(s.bind(null,"0151"))},uUpload:function(){return Promise.all([s.e("common/vendor"),s.e("node-modules/uview-ui/components/u-upload/u-upload")]).then(s.bind(null,"5220"))},"u-Textarea":function(){return Promise.all([s.e("common/vendor"),s.e("node-modules/uview-ui/components/u--textarea/u--textarea")]).then(s.bind(null,"d17b"))},uPicker:function(){return Promise.all([s.e("common/vendor"),s.e("node-modules/uview-ui/components/u-picker/u-picker")]).then(s.bind(null,"2ce3"))},hbxwDateRangePicker:function(){return Promise.all([s.e("common/vendor"),s.e("uni_modules/hbxw-date-range-picker/components/hbxw-date-range-picker/hbxw-date-range-picker")]).then(s.bind(null,"03fa"))}},a=function(){var t=this,e=t.$createElement,s=(t._self._c,t.formList.length);t._isMounted||(t.e0=function(e){e.stopPropagation(),t.teacherShow=!0},t.e1=function(e){e.stopPropagation(),t.classesShow=!0},t.e2=function(e){e.stopPropagation(),t.selfhotShow=!0},t.e3=function(e){e.stopPropagation(),t.disable&&(t.shangShow=!0)},t.e4=function(e){e.stopPropagation(),t.typeShow=!0},t.e5=function(e){e.stopPropagation(),t.address_typeShow=!0},t.e6=function(e){e.stopPropagation(),t.districtShow=!0}),t.$mp.data=Object.assign({},{$root:{g0:s}})},o=[]},"7c16":function(t,e,s){"use strict";s.r(e);var i=s("4683"),a=s("2f33");for(var o in a)["default"].indexOf(o)<0&&function(t){s.d(e,t,(function(){return a[t]}))}(o);s("856d");var n=s("828b"),r=Object(n["a"])(a["default"],i["b"],i["c"],!1,null,"71df23f2",null,!1,i["a"],void 0);e["default"]=r.exports},"856d":function(t,e,s){"use strict";var i=s("26dc"),a=s.n(i);a.a},"9fff":function(t,e,s){"use strict";(function(t){var i=s("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=i(s("7eb4")),o=i(s("34cf")),n=i(s("7ca3")),r=i(s("ee10"));function c(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,i)}return s}function l(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?c(Object(s),!0).forEach((function(e){(0,n.default)(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):c(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}var u={data:function(){return{teacherShow:!1,teacherList:[],classesShow:!1,classesTypeList:[],selfhotShow:!1,selfhotList:[["是","否"]],typeShow:!1,typeList:[["室内","室外"]],districtShow:!1,districtList:[],statusShow:!1,shangShow:!1,shangList:[[{label:"是",value:1},{label:"否",value:2}]],statusList:[[{label:"上架",value:1},{label:"下架",value:2}]],address_typeList:[["机构内授课","特定位置授课"]],address_typeShow:!1,localShow:!1,form:{latitude:"",longitude:"",address_detail:"",teacher_id:"",teacher:"",classes:"",classes_type:"",title:"",price:"",verification_num:"",location_type:"",address_type:"机构内授课",address:"",course_details:"",course:"",selfhot:"否",type:"室内",classes_cate_ids:"",classes_label_ids:"",notice:"",content:"",status_name:"是",status:"1",classes_num:"1",district_name:"",district:""},dateReangeVisible:!1,currentPeriodIndex:null,currentTimeType:null,date:null,formList:[{name:"",start_time:"",end_time:"",limit_num:"",status_name:"",status:"1",visible:!0}],fileList1:[],fileList2:[],list1:"",list2:"",disable:!0,classes_cateList:[],classes_labelList:[]}},watch:{value1:{handler:function(t,e){},deep:!0,immediate:!0}},onLoad:function(t){this.initData(t)},methods:{initData:function(e){var s=this;return(0,r.default)(a.default.mark((function i(){var o;return a.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:return o=[s.getTeacherList(e.shop_id),s.getclassesTypeList(),s.getclassesList(),s.getclasses_labelList(),s.getdistrictList()],i.prev=1,i.next=4,Promise.all(o);case 4:if(!e.id){i.next=9;break}return s.disable=!1,t.setNavigationBarTitle({title:"编辑课程"}),i.next=9,s.getDetail(e.id);case 9:i.next=15;break;case 11:i.prev=11,i.t0=i["catch"](1),console.error("加载数据时发生错误:",i.t0),t.showToast({title:"加载数据失败,请重试",icon:"none",duration:2e3});case 15:case"end":return i.stop()}}),i,null,[[1,11]])})))()},addPeriod:function(){this.formList.push({name:"",start_time:"",end_time:"",limit_num:"",status:1,visible:!0})},getDetail:function(e){var s=this;return(0,r.default)(a.default.mark((function i(){var o,n,r,c,u;return a.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,t.$u.http.get("/api/school/classes/detail",{params:{id:e}});case 3:if(o=i.sent,1!=o.code){i.next=35;break}s.form=o.data.detail,console.log("form.classes_type:",s.form.classes_type),console.log("classesTypeList:",s.classesTypeList),n={},s.classesTypeList[0].forEach((function(t){n[t.id]=t.name})),console.log("classes_typeMap:",n),s.form.classes=n[s.form.classes_type]||"",r={},s.teacherList[0].forEach((function(t){r[t.id]=t.name})),s.form.teacher=r[s.form.teacher.id]||"",1==s.form.status&&(s.form.status_name="是"),1==s.form.status?s.form.status_name="否":s.form.status_name="审核中",s.form.type="in"==s.form.type?"室内":"室外",s.form.address_type=1==s.form.address_type?"机构内授课":"特定位置授课",2==s.form.address_type&&(s.localShow=!0),c={},s.districtList.forEach((function(t){c[t.value]=t.label})),s.form.district_name=c[s.form.district]||"",s.formList=o.data.detail.specs.map((function(t){return{name:t.name,end_time:t.end_time_text,weigh:t.weigh,start_time:t.start_time_text,limit_num:t.limit_num,id:t.id,status:t.status}})),u={},s.statusList.forEach((function(t){u[t.value]=t.label})),s.formList=s.formList.map((function(t){return l(l({},t),{},{status_name:u[t.status]||""})})),s.form.classes_cate_ids=s.form.classes_cate_ids.split(","),s.form.classes_label_ids=s.form.classes_label_ids.split(","),s.fileList1=s.formatImagesToFiles(s.form.headimage.split(",")),s.list1=s.form.headimage,s.list2=s.form.images.join(","),s.fileList2=s.formatImagesToFiles(s.form.images),i.next=37;break;case 35:throw t.showToast({title:o.msg,icon:"none",duration:2e3}),new Error(o.msg);case 37:i.next=43;break;case 39:throw i.prev=39,i.t0=i["catch"](0),console.error("请求失败",i.t0),i.t0;case 43:case"end":return i.stop()}}),i,null,[[0,39]])})))()},formatImagesToFiles:function(t){return t.map((function(t,e){return{url:t,name:"image".concat(e+1,".jpg")}}))},getdistrictList:function(){var e=this;t.$u.http.get("/api/index/get_area",{params:{province:"410000",city:"410300"}}).then((function(s){1==s.code?e.districtList[0]=s.data.map((function(t){return{label:t.label,value:t.value}})):t.showToast({title:s.msg,icon:"none",duration:2e3})})).catch((function(t){console.error("请求失败",t)}))},getclassesList:function(){var e=this;t.$u.http.get("/api/school/classes/cate_list",{}).then((function(s){1==s.code?e.classes_cateList=s.data.list.map((function(t){return{label:t.name,value:t.id}})):t.showToast({title:s.msg,icon:"none",duration:2e3})})).catch((function(t){console.error("请求失败",t)}))},getclasses_labelList:function(){var e=this;t.$u.http.get("/api/school/classes/label_list",{}).then((function(s){1==s.code?e.classes_labelList=s.data.list.map((function(t){return{label:t.name,value:t.id}})):t.showToast({title:s.msg,icon:"none",duration:2e3})})).catch((function(t){console.error("请求失败",t)}))},getTeacherList:function(e){var s=this;t.$u.http.get("/api/school/teacher/teacher_list",{params:{shop_id:e}}).then((function(e){1==e.code?s.teacherList[0]=e.data.list:t.showToast({title:e.msg,icon:"none",duration:2e3})})).catch((function(t){console.error("请求失败",t)}))},getclassesTypeList:function(){var e=this;t.$u.http.get("/api/school/classes/type_list",{}).then((function(s){1==s.code?e.classesTypeList[0]=s.data.list:t.showToast({title:s.msg,icon:"none",duration:2e3})})).catch((function(t){console.error("请求失败",t)}))},choose:function(){var e=this;t.chooseLocation({success:function(t){console.log(t),e.form.address=t.name,e.form.latitude=t.latitude,e.form.longitude=t.longitude},fail:function(t){console.log(t)}})},districtCancel:function(t){this.teacherShow=!1},districtConfirm:function(t){console.log(t.value),this.form.district=t.value[0].value,this.form.district_name=t.value[0].label,this.districtShow=!1},teacherCancel:function(t){this.teacherShow=!1},teacherConfirm:function(t){console.log(t.value),this.form.teacher_id=t.value[0].id,this.form.teacher=t.value[0].name,this.teacherShow=!1},isStatus:function(t){this.currentPeriodIndex=t,this.statusShow=!0},statusCancel:function(t){this.statusShow=!1},statusConfirm:function(t){console.log(t.value);var e=this.currentPeriodIndex;null!==e&&(this.$set(this.formList[e],"status",t.value[0].value),this.$set(this.formList[e],"status_name",t.value[0].label)),this.statusShow=!1},shangCancel:function(t){this.shangShow=!1},shangConfirm:function(t){this.form.status=t.value[0].value,this.form.status_name=t.value[0].label,this.shangShow=!1},classesCancel:function(t){this.classesShow=!1},classesConfirm:function(t){console.log(t.value),this.form.classes_type=t.value[0].id,this.form.classes=t.value[0].name,this.classesShow=!1},selfhotCancel:function(t){this.selfhotShow=!1},selfhotConfirm:function(t){console.log(t.value),this.form.selfhot=t.value[0],this.selfhotShow=!1},typeCancel:function(t){this.typeShow=!1},typeConfirm:function(t){console.log(t.value),this.form.type=t.value[0],this.typeShow=!1},address_typeCancel:function(t){this.address_typeShow=!1},address_typeConfirm:function(t){console.log(t.value),this.form.address_type=t.value[0],this.address_typeShow=!1,"特定位置授课"==t.value[0]?this.localShow=!0:(this.localShow=!1,this.form.province="",this.form.city="",this.form.district="",this.form.address="",this.form.address_detail="",this.form.longitude="",this.form.latitude="")},selctTime:function(t){this.currentPeriodIndex=t,this.dateReangeVisible=!0},cancel:function(){this.dateReangeVisible=!1},sure:function(t){var e=this.currentPeriodIndex;console.log(t),null!==e&&(this.$set(this.formList[e],"start_time",t.startStr),this.$set(this.formList[e],"end_time",t.endStr)),this.dateReangeVisible=!1},dateChange:function(t){console.log("---- change ----:",t),this.date=t},removePeriod:function(t){this.formList.splice(t,1),this.formList[t].visible=!1},change:function(t){console.log("e:",t)},oversize:function(t){return this.$u.toast("请传2MB以内大小的图片"),!1},deletePic:function(t){console.log(t);var e=t.name,s=t.index;if(s>=0&&s<this["fileList".concat(e)].length){this["fileList".concat(e)].splice(s,1),"1"===e?(this.list1=this.fileList1.length>0?this.fileList1[0].url:"",console.log("Updated list1:",this.list1)):"2"===e&&(this.list2=this.fileList2.map((function(t){return t.url})).join(","),console.log("Updated list2:",this.list2));var i=this["list".concat(e)];Array.isArray(i)?(i.splice(s,1),console.log("Updated list".concat(e,":"),i)):console.warn("list".concat(e," is not an array, skipping splice operation"))}else console.error("Invalid index")},afterRead:function(t){var e=this;return(0,r.default)(a.default.mark((function s(){var i,o,n,r,c,u;return a.default.wrap((function(s){while(1)switch(s.prev=s.next){case 0:i=[].concat(t.file),o=e["fileList".concat(t.name)].length,i.map((function(s){e["fileList".concat(t.name)].push(l(l({},s),{},{status:"uploading",message:"上传中"}))})),n=0;case 4:if(!(n<i.length)){s.next=16;break}return s.next=7,e.uploadFilePromise(i[n].url);case 7:r=s.sent,c=e["fileList".concat(t.name)][o],e["fileList".concat(t.name)].splice(o,1,Object.assign(c,{status:"success",message:"",url:r})),console.log(e["fileList".concat(t.name)]," this[`fileList${event.name}`]"),o++,"1"===t.name?e.list1=(null===(u=e.fileList1[0])||void 0===u?void 0:u.url)||"":"2"===t.name&&(e.list2=e.fileList2.map((function(t){return t.url})).join(","));case 13:n++,s.next=4;break;case 16:case"end":return s.stop()}}),s)})))()},uploadFilePromise:function(e){return new Promise((function(s,i){t.uploadFile({url:"https://testy.hschool.com.cn//api/school.worker.common/upload",filePath:e,name:"file",formData:{user:"test"},header:{token:t.getStorageSync("token")},success:function(t){s(JSON.parse(t.data).data.fullurl)},fail:function(t){i(t)}})}))},add:function(){console.log(this.formList),this.formList.forEach((function(t){var e,s;if(t.start_time.includes("年")){var i=t.start_time.match(/(\d{4})年(\d{1,2})月(\d{1,2})日 (\d{2}:\d{2})/).slice(1),a=(0,o.default)(i,4),n=a[0],r=a[1],c=a[2],l=a[3];e="".concat(n,"/").concat(r.padStart(2,"0"),"/").concat(c.padStart(2,"0")," ").concat(l)}else{var u=t.start_time.match(/(\d{4})-(\d{1,2})-(\d{1,2}) (\d{2}:\d{2}):(\d{2})/).slice(1),d=(0,o.default)(u,4),f=d[0],h=d[1],m=d[2],p=d[3];e="".concat(f,"/").concat(h.padStart(2,"0"),"/").concat(m.padStart(2,"0")," ").concat(p)}if(t.end_time.includes("年")){var _=t.end_time.match(/(\d{4})年(\d{1,2})月(\d{1,2})日 (\d{2}:\d{2})/).slice(1),g=(0,o.default)(_,4),v=g[0],b=g[1],w=g[2],y=g[3];s="".concat(v,"/").concat(b.padStart(2,"0"),"/").concat(w.padStart(2,"0")," ").concat(y)}else{var L=t.end_time.match(/(\d{4})-(\d{1,2})-(\d{1,2}) (\d{2}:\d{2}):(\d{2})/).slice(1),S=(0,o.default)(L,4),P=S[0],x=S[1],k=S[2],T=S[3];s="".concat(P,"/").concat(x.padStart(2,"0"),"/").concat(k.padStart(2,"0")," ").concat(T)}t.time="".concat(e," - ").concat(s)}));var e={},s="";this.disable?(s="/api/school.worker.classes/add",e={classes_num:this.form.classes_num,status:this.form.status,teacher_id:this.form.teacher_id,classes_type:this.form.classes_type,classes_cate_ids:this.form.classes_cate_ids.join(","),classes_label_ids:this.form.classes_label_ids.join(","),self_label_tag:this.form.self_label_tag,title:this.form.title,headimage:this.list1,images:this.list2,type:"室内"==this.form.type?"in":"out",address_type:"机构内授课"==this.form.address_type?1:2,province:"410000",city:"410300",content:this.form.content,notice:this.form.notice,price:this.form.price,selfhot:"是"==this.form.selfhot?"1":0,address_detail:this.form.address_detail,address:this.form.address,longitude:this.form.longitude,latitude:this.form.latitude,spec:JSON.stringify(this.formList),district:this.form.district}):(s="/api/school.worker.classes/edit",e={id:this.form.id,classes_num:this.form.classes_num,status:this.form.status,teacher_id:this.form.teacher_id,classes_type:this.form.classes_type,classes_cate_ids:this.form.classes_cate_ids.join(","),classes_label_ids:this.form.classes_label_ids.join(","),self_label_tag:this.form.self_label_tag,title:this.form.title,headimage:this.list1,images:this.list2,type:"室内"==this.form.type?"in":"out",address_type:"机构内授课"==this.form.address_type?1:2,province:"410000",city:"410300",content:this.form.content,notice:this.form.notice,price:this.form.price,selfhot:"是"==this.form.selfhot?"1":0,address_detail:this.form.address_detail,address:this.form.address,longitude:this.form.longitude,latitude:this.form.latitude,spec:JSON.stringify(this.formList),district:this.form.district}),t.$u.http.post(s,e).then((function(e){1==e.code?t.showToast({title:e.msg,icon:"none",duration:2e3,complete:function(){setTimeout((function(){t.navigateBack(1)}),2e3)}}):t.showToast({title:e.msg,icon:"none",duration:2e3})})).catch((function(t){console.error("请求失败",t)}))}}};e.default=u}).call(this,s("df3c")["default"])}},[["0a1a","common/runtime","common/vendor"]]]);