12 lines
9.9 KiB
JavaScript
12 lines
9.9 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["node-modules/@dcloudio/uni-cli-shared/components/unicloud-db"],{732:function(t,e,n){"use strict";n.r(e);var i=n(733),o=n(735);for(var a in o)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return o[t]}))}(a);var r,s=n(46),l=Object(s["default"])(o["default"],i["render"],i["staticRenderFns"],!1,null,null,null,!1,i["components"],r);l.options.__file="Program Files/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/uni-cli-shared/components/unicloud-db.vue",e["default"]=l.exports},733:function(t,e,n){"use strict";n.r(e);var i=n(734);n.d(e,"render",(function(){return i["render"]})),n.d(e,"staticRenderFns",(function(){return i["staticRenderFns"]})),n.d(e,"recyclableRender",(function(){return i["recyclableRender"]})),n.d(e,"components",(function(){return i["components"]}))},734:function(t,e,n){"use strict";var i;n.r(e),n.d(e,"render",(function(){return o})),n.d(e,"staticRenderFns",(function(){return r})),n.d(e,"recyclableRender",(function(){return a})),n.d(e,"components",(function(){return i}));var o=function(){var t=this,e=t.$createElement;t._self._c;t.$initSSP(),"augmented"===t.$scope.data.scopedSlotsCompiler&&t.$setSSP("default",{options:t.options,data:t.dataList,pagination:t.paginationInternal,loading:t.loading,hasMore:t.hasMore,error:t.errorMessage}),t.$callSSP()},a=!1,r=[];o._withStripped=!0},735:function(t,e,n){"use strict";n.r(e);var i=n(736),o=n.n(i);for(var a in i)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(a);e["default"]=o.a},736:function(t,e,n){"use strict";(function(t,i){var o=n(4);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=o(n(18)),r=o(n(13)),s=n(22),l=o(n(737)),c=(0,s.initVueI18n)(l.default),d=c.t,u={load:"load",error:"error"},h={add:"add",replace:"replace"},f={auto:"auto",onready:"onready",manual:"manual"},p=["pageCurrent","pageSize","spaceInfo","collection","action","field","getcount","orderby","where","groupby","groupField","distinct"],g={name:"UniClouddb",props:{options:{type:[Object,Array],default:function(){return{}}},spaceInfo:{type:Object,default:function(){return{}}},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},getone:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String,Object],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},pageIndistinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:function(){return{loading:!1,hasMore:!1,dataList:this.getone?void 0:[],paginationInternal:{},errorMessage:""}},computed:{collectionArgs:function(){return Array.isArray(this.collection)?this.collection:[this.collection]},isLookup:function(){return Array.isArray(this.collection)&&this.collection.length>1||"string"===typeof this.collection&&this.collection.indexOf(",")>-1}},created:function(){var t=this;this._isEnded=!1,this.paginationInternal={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((function(){var e=[];return p.forEach((function(n){e.push(t[n])})),e}),(function(e,n){if(t.paginationInternal.size=t.pageSize,e[0]!==n[0]&&(t.paginationInternal.current=t.pageCurrent),t.loadtime!==f.manual){for(var i=!1,o=2;o<e.length;o++)if(e[o]!==n[o]){i=!0;break}i&&(t.clear(),t.reset()),t._execLoadData()}})),this.manual||this.loadtime!==f.auto||this.loadData()},methods:{loadData:function(t,e){var n=null,i=!1;"object"===(0,r.default)(t)?(t.clear&&(this.pageData===h.replace?this.clear():i=t.clear,this.reset()),void 0!==t.current&&(this.paginationInternal.current=t.current),"function"===typeof e&&(n=e)):"function"===typeof t&&(n=t),this._execLoadData(n,i)},loadMore:function(){this._isEnded||this.loading||(this.pageData===h.add&&this.paginationInternal.current++,this._execLoadData())},refresh:function(){this.clear(),this._execLoadData()},clear:function(){this._isEnded=!1,this.dataList=[]},reset:function(){this.paginationInternal.current=1},add:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.action,a=n.showToast,r=void 0===a||a,s=n.toastTitle,l=n.success,c=n.fail,u=n.complete,h=n.needConfirm,f=void 0===h||h,p=n.needLoading,g=void 0===p||p,m=n.loadingTitle,v=void 0===m?"":m;g&&t.showLoading({title:v});var y=i.database(this.spaceInfo);o&&(y=y.action(o)),y.collection(this.getMainCollection()).add(e).then((function(e){l&&l(e),r&&t.showToast({title:s||d("uniCloud.component.add.success")})})).catch((function(e){c&&c(e),f&&t.showModal({content:e.message,showCancel:!1})})).finally((function(){g&&t.hideLoading(),u&&u()}))},remove:function(e){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.action,a=i.success,r=i.fail,s=i.complete,l=i.confirmTitle,c=i.confirmContent,u=i.needConfirm,h=void 0===u||u,f=i.needLoading,p=void 0===f||f,g=i.loadingTitle,m=void 0===g?"":g;e&&e.length&&(h?t.showModal({title:l||d("uniCloud.component.remove.showModal.title"),content:c||d("uniCloud.component.remove.showModal.content"),showCancel:!0,success:function(t){t.confirm&&n._execRemove(e,o,a,r,s,h,p,m)}}):this._execRemove(e,o,a,r,s,h,p,m))},update:function(e,n){var i=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=Object.assign({action:null,showToast:!0,toastTitle:null,success:null,fail:null,complete:null,confirmTitle:null,confirmContent:null,needConfirm:!0,needLoading:!0,loadingTitle:""},o);o.needConfirm?t.showModal({title:o.confirmTitle||d("uniCloud.component.update.showModal.title"),content:o.confirmContent||d("uniCloud.component.update.showModal.content"),showCancel:!0,success:function(t){t.confirm&&i._doUpdate(e,n,a)}}):this._doUpdate(e,n,a)},_doUpdate:function(e,n,o){var a=o.action,r=o.success,s=o.fail,l=o.complete,c=o.showToast,u=o.toastTitle,h=o.needConfirm,f=o.needLoading,p=o.loadingTitle;f&&t.showLoading({title:p});var g=i.database(this.spaceInfo);a&&(g=g.action(a)),g.collection(this.getMainCollection()).doc(e).update(n).then((function(e){r&&r(e),c&&t.showToast({title:u||d("uniCloud.component.update.success")})})).catch((function(e){s&&s(e),h&&t.showModal({content:e.message,showCancel:!1})})).finally((function(){f&&t.hideLoading(),l&&l()}))},getMainCollection:function(){if("string"===typeof this.collection)return this.collection.split(",")[0];var t=JSON.parse(JSON.stringify(this.collection[0]));return t.$db[0].$param[0]},getTemp:function(){var t,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=i.database(this.spaceInfo);this.action&&(n=n.action(this.action)),n=(t=n).collection.apply(t,(0,a.default)(this.collectionArgs)),this.foreignKey&&(n=n.foreignKey(this.foreignKey)),this.where&&Object.keys(this.where).length&&(n=n.where(this.where)),this.field&&(n=n.field(this.field)),this.groupby&&(n=n.groupBy(this.groupby)),this.groupField&&(n=n.groupField(this.groupField)),!0===this.distinct&&(n=n.distinct()),this.orderby&&(n=n.orderBy(this.orderby));var o=this.paginationInternal,r=o.current,s=o.size,l={};this.getcount&&(l.getCount=this.getcount);var c={limitLevel:this.limitlevel,startWith:this.startwith};return this.gettree&&(l.getTree=c),this.gettreepath&&(l.getTreePath=c),n=n.skip(s*(r-1)).limit(s),e?(n=n.getTemp(l),n.udb=this):n=n.get(l),n},setResult:function(t){0===t.code?this._execLoadDataSuccess(t):this._execLoadDataFail(new Error(t.message))},_execLoadData:function(t,e){var n=this;this.loading||(this.loading=!0,this.errorMessage="",this._getExec().then((function(i){n.loading=!1,n._execLoadDataSuccess(i.result,t,e)})).catch((function(e){n.loading=!1,n._execLoadDataFail(e,t)})))},_execLoadDataSuccess:function(t,e,n){var i=t.data,o=t.count;this._isEnded=void 0!==o?this.paginationInternal.current*this.paginationInternal.size>=o:i.length<this.pageSize,this.hasMore=!this._isEnded;var r,s=this.getone?i.length?i[0]:void 0:i;(this.getcount&&(this.paginationInternal.count=o),e&&e(s,this._isEnded,this.paginationInternal),this._dispatchEvent(u.load,s),this.getone||this.pageData===h.replace)?this.dataList=s:n?this.dataList=s:(r=this.dataList).push.apply(r,(0,a.default)(s))},_execLoadDataFail:function(t,e){this.errorMessage=t,e&&e(),this.$emit(u.error,t),console.error(t)},_getExec:function(){return this.getTemp(!1)},_execRemove:function(e,n,o,a,r,s,l,c){var d=this;if(this.collection&&e){var u=Array.isArray(e)?e:[e];if(u.length){l&&t.showLoading({mask:!0,title:c});var f=i.database(this.spaceInfo),p=f.command,g=f;n&&(g=g.action(n)),g.collection(this.getMainCollection()).where({_id:p.in(u)}).remove().then((function(t){o&&o(t.result),d.pageData===h.replace?d.refresh():d.removeData(u)})).catch((function(e){a&&a(e),s&&t.showModal({content:e.message,showCancel:!1})})).finally((function(){l&&t.hideLoading(),r&&r()}))}}},removeData:function(t){for(var e=t.slice(0),n=this.dataList,i=n.length-1;i>=0;i--){var o=e.indexOf(n[i]._id);o>=0&&(n.splice(i,1),e.splice(o,1))}},_dispatchEvent:function(t,e){this._changeDataFunction?this._changeDataFunction(e,this._isEnded,this.paginationInternal):this.$emit(t,e,this._isEnded,this.paginationInternal)}}};e.default=g}).call(this,n(2)["default"],n(27)["uniCloud"])}}]);
|
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/@dcloudio/uni-cli-shared/components/unicloud-db.js.map
|
|
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
|
|
'node-modules/@dcloudio/uni-cli-shared/components/unicloud-db-create-component',
|
|
{
|
|
'node-modules/@dcloudio/uni-cli-shared/components/unicloud-db-create-component':(function(module, exports, __webpack_require__){
|
|
__webpack_require__('2')['createComponent'](__webpack_require__(732))
|
|
})
|
|
},
|
|
[['node-modules/@dcloudio/uni-cli-shared/components/unicloud-db-create-component']]
|
|
]);
|