space.vue.subassembly.js 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199
  1. /**
  2. * 按钮组
  3. */
  4. Vue.component('spaceButtonTabs', {
  5. data: function () {
  6. return {
  7. mappingObj: {},
  8. }
  9. },
  10. name: "spaceButtonTabs",
  11. model: {
  12. prop: 'modelVal',
  13. evnet: 'click'
  14. },
  15. props: ['modelVal', "data", "mapping", "label"],
  16. created: function () {
  17. this.initMapping();
  18. },
  19. methods: {
  20. change: function (val) {
  21. this.$emit("input", val);
  22. space.plugin.search.submit();
  23. },
  24. initMapping: function () {
  25. if (!this.mapping) {
  26. this.mapping = {};
  27. }
  28. if (space.utils.isNull(this.mapping.name)) {
  29. this.mapping.name = "name";
  30. }
  31. if (space.utils.isNull(this.mapping.value)) {
  32. this.mapping.value = "value";
  33. }
  34. this.mappingObj = this.mapping;
  35. }
  36. },
  37. template: `
  38. <div class="component-wrap">
  39. <div class="main-AdSearch-title" v-if="space.utils.notNull(label)">{{label}}</div>
  40. <ul class="main-tabs-ul">
  41. <li v-for="(item) in data" :class="{'tabs-active' : modelVal == item[mappingObj.value]}" @click="change(item[mappingObj.value])">
  42. <a href="javascript:;">
  43. {{item[mappingObj.name]}}
  44. </a>
  45. </li>
  46. </ul>
  47. </div>
  48. `
  49. })
  50. /**
  51. * Picker 组件
  52. */
  53. Vue.component('spacePicker', {
  54. data: function () {
  55. return {
  56. id: "SpacePicker" + space.utils.random(6),
  57. txt: '',
  58. mobileSelect: undefined,
  59. selectIndexArr: undefined,
  60. keyMaps: {},
  61. }
  62. },
  63. name: "spacePicker",
  64. // 选中的值,列名,数据,数据键转换,校验,返回值格式
  65. props: ["value", "label", "wheels", "keymap", "rules", "valpath"],
  66. created: function () {
  67. this.keyMaps = space.utils.cloneObj(this.initKeyMap(this.keymap));
  68. },
  69. mounted: function () {
  70. if (space.utils.isNull(this.value)) {
  71. $("#" + this.id).find("div.van-field__right-icon").hide();
  72. }
  73. this.initMobileSelect();
  74. if (this.mobileSelect) {
  75. this.selectPickerValue(this.value);
  76. }
  77. },
  78. watch: {
  79. value: function (newVal, oldVal) {
  80. // 需要指定选择项
  81. this.selectPickerValue(newVal);
  82. var iconDom = $("#" + this.id).find("div.van-field__right-icon");
  83. if (space.utils.notNull(newVal)) {
  84. $(iconDom).show();
  85. } else {
  86. $(iconDom).hide();
  87. }
  88. this.$emit('change', newVal);
  89. },
  90. wheels: function (newVal, oldVal) {
  91. // 需要重新渲染数据
  92. if (!this.mobileSelect) {
  93. this.initMobileSelect();
  94. this.selectPickerValue(this.value);
  95. return;
  96. }
  97. // 判断是否存在级联,以调用不同的渲染方法,存在为真,否则为假
  98. var isExistChildrenFlag = false;
  99. if (space.utils.notNull(newVal) && JSON.stringify(newVal).indexOf(this.keyMaps.childs) != -1) {
  100. isExistChildrenFlag = true;
  101. }
  102. // 存在级联
  103. if (isExistChildrenFlag) {
  104. this.mobileSelect.updateWheels(newVal);
  105. } else {
  106. if (space.utils.isNull(newVal)) {
  107. this.mobileSelect.updateWheels({});
  108. this.mobileSelect.updateWheel(0, {});
  109. } else {
  110. this.mobileSelect.updateWheel(0, newVal);
  111. }
  112. }
  113. this.fieldClear();
  114. },
  115. valpath: function (newVal, oldVal) {
  116. // 默认是 false,如果是true,返回完整的数组,如果是false,返回最后一列的ID
  117. this.valpath = space.utils.isNull(newVal) ? false : newVal;
  118. }
  119. },
  120. methods: {
  121. /**
  122. * 初始化 keymap,{id: '隐藏值的 key,默认 value', value: '显示值的 key,默认 text', childs: '子节点的 key,默认 children'}
  123. * @param {Object} keymap
  124. */
  125. initKeyMap: function (km) {
  126. if (!km) {
  127. km = {
  128. id: 'value',
  129. value: 'text',
  130. childs: 'children'
  131. }
  132. }
  133. if (!km.id) {
  134. km.id = 'value';
  135. }
  136. if (!km.value) {
  137. km.value = 'text';
  138. }
  139. if (!km.childs) {
  140. km.childs = 'children';
  141. }
  142. return km;
  143. },
  144. /**
  145. * 初始化滚动选择器
  146. */
  147. initMobileSelect: function () {
  148. var that = this;
  149. // 防止初始化滚动选择器时,没有数据问题
  150. if (that.wheels == undefined || that.wheels.length == 0) {
  151. return;
  152. }
  153. this.mobileSelect = new MobileSelect({
  154. trigger: "#" + that.id,
  155. // title: that.label,
  156. wheels: [{
  157. data: that.wheels || []
  158. }],
  159. keyMap: that.keyMaps,
  160. connector: ' / ',
  161. position: [],
  162. triggerDisplayData: false,
  163. onShow: function () {
  164. if (space.utils.isNull(that.wheels)) {
  165. that.mobileSelect.hide();
  166. space.message.warning("没有任何可选项");
  167. return;
  168. }
  169. if (!that.selectIndexArr) {
  170. return;
  171. }
  172. for (var i = 0; i < that.selectIndexArr.length; i++) {
  173. that.mobileSelect.locatePosition(i, that.selectIndexArr[i]);
  174. }
  175. },
  176. callback: function (indexArr, data) {
  177. // 默认是 false,如果是true,返回完整的数组,如果是false,返回最后一列的ID
  178. that.valpath = space.utils.isNull(that.valpath) ? false : that.valpath;
  179. if (that.valpath) {
  180. that.$emit("input", data);
  181. } else {
  182. that.$emit("input", data[data.length - 1][that.keyMaps.id]);
  183. }
  184. this.position = indexArr;
  185. that.selectIndexArr = indexArr;
  186. }
  187. });
  188. },
  189. /**
  190. * 选中值
  191. * @param {Object} value
  192. */
  193. selectPickerValue: function (value) {
  194. var val = value;
  195. // 是数组 []
  196. if (value instanceof Array && value.length > 0) {
  197. val = value[value.length - 1][this.keyMaps.id];
  198. }
  199. var map = this.getMobileSelectIndexAndText({
  200. data: this.wheels,
  201. keyMap: this.keyMaps,
  202. selectValue: val
  203. });
  204. if (!map) {
  205. // 防止已经选了值,再次赋值时未找到选项的时候,页面还显示原值的问题
  206. this.fieldClear();
  207. return;
  208. }
  209. for (var i = 0; i < map.indexAry.length; i++) {
  210. this.mobileSelect.locatePosition(i, map.indexAry[i]);
  211. }
  212. this.txt = map.text;
  213. this.selectIndexArr = map.indexAry;
  214. },
  215. /**
  216. * 获取移动端下拉框选中的下标与文本
  217. *
  218. * @param {Object} setting {data: [下拉框数据], keyMap: {id: '隐藏值的 key,默认 value', value: '显示值的 key,默认 text', childs: '子节点的 key,默认 children'}, selectValue: '选中的值'}
  219. */
  220. getMobileSelectIndexAndText: function (setting) {
  221. if (!setting.data) {
  222. return undefined;
  223. }
  224. setting.keyMap = this.keyMaps;
  225. const indexAry = [];
  226. const selectTextAry = [];
  227. this.getSelectedByValue(setting.data, setting.keyMap, setting.selectValue, indexAry, selectTextAry);
  228. if (indexAry.length == 0 && selectTextAry.length == 0) {
  229. return undefined;
  230. }
  231. return {
  232. indexAry: indexAry,
  233. text: selectTextAry.join(" / ")
  234. };
  235. },
  236. /**
  237. * 根据选中的值,获取在数据数组中的索引数组
  238. *
  239. * @param {Object} data 下拉框数据
  240. * @param {Object} kayMap 数据的 key map 值,{id: '隐藏值的 key,默认 value', value: '显示值的 key,默认 text', childs: '子节点的 key,默认 children'}
  241. * @param {Object} selectValue 选中的值
  242. * @param {Object} indexAry 选中的下标数组
  243. * @param {Object} selectTextAry 选中的回显值数组
  244. */
  245. getSelectedByValue: function (data, kayMap, selectValue, indexAry, selectTextAry) {
  246. for (let i = 0; i < data.length; i++) {
  247. if (data[i][kayMap.id] == selectValue) {
  248. data.defaultIndex = i;
  249. indexAry.splice(0, 0, i); // 把 i 插入到索引为 0 的位置上
  250. selectTextAry.splice(0, 0, data[i][kayMap.value]);
  251. return true;
  252. }
  253. if (data[i][kayMap.childs]) {
  254. const flag = this.getSelectedByValue(data[i][kayMap.childs], kayMap, selectValue, indexAry, selectTextAry);
  255. if (flag) {
  256. data.defaultIndex = i;
  257. indexAry.splice(0, 0, i); // 把 i 插入到索引为 0 的位置上
  258. selectTextAry.splice(0, 0, data[i][kayMap.value]);
  259. return true;
  260. }
  261. }
  262. }
  263. return false;
  264. },
  265. /**
  266. * 清空
  267. */
  268. fieldClear: function () {
  269. this.txt = "";
  270. this.$emit("input", "");
  271. if (this.mobileSelect) {
  272. this.mobileSelect.locatePosition(0, 0);
  273. }
  274. this.selectIndexArr = undefined;
  275. if (event) {
  276. event.stopPropagation();
  277. }
  278. $("#" + this.id).find("div.van-field__right-icon").hide();
  279. },
  280. warpClick: function () {
  281. if (!this.mobileSelect) {
  282. space.message.warning("没有任何可选项");
  283. }
  284. }
  285. },
  286. template: `
  287. <div class="component-wrap" :id="id" @click="warpClick" >
  288. <van-field :rules="rules" readonly clickable clearable right-icon="clear" :value="txt" :label="label" :placeholder="'点击选择'+label" @click-right-icon="fieldClear" ></van-field>
  289. </div>
  290. `
  291. })
  292. /**
  293. * Calendar 日历组件
  294. */
  295. Vue.component('spaceCalendar', {
  296. data: function () {
  297. return {
  298. id: "spaceDatetimePicker" + space.utils.random(6),
  299. isShow: false,
  300. txt: "",
  301. }
  302. },
  303. name: "spaceCalendar",
  304. props: ["value", "label", "rules"],
  305. mounted: function () {
  306. if (space.utils.isNull(this.value)) {
  307. $("#" + this.id).find("div.van-field__right-icon").hide();
  308. }
  309. },
  310. methods: {
  311. /**
  312. * 清空
  313. */
  314. fieldClear: function () {
  315. this.txt = "";
  316. this.isShow = false;
  317. this.$emit("input", "");
  318. event.stopPropagation();
  319. $("#" + this.id).find("div.van-field__right-icon").hide();
  320. },
  321. formatDate: function (date) {
  322. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
  323. },
  324. onConfirm: function (date) {
  325. this.isShow = false;
  326. this.txt = this.formatDate(date);
  327. $("#" + this.id).find("div.van-field__right-icon").show();
  328. this.$emit("input", this.txt);
  329. }
  330. },
  331. template: `
  332. <div class="component-wrap" :id="id">
  333. <van-field :rules="rules" readonly clickable clearable right-icon="clear" :value="txt" :label="label" :placeholder="'点击选择'+label" @click="isShow = true;" @click-right-icon="fieldClear"></van-field>
  334. <van-calendar v-model="isShow" @confirm="onConfirm"></van-calendar>
  335. </div>
  336. `
  337. })
  338. /**
  339. * DatetimePicker 组件
  340. * type 时间类型,可选值为 date time year-month month-day datehour
  341. * type 的值为year-month,同时 typeflag 的值 year,即是选择年份
  342. * type 的值为datetime,同时 typeflag 的值 noyear,即是选择月日时分,没有年份
  343. */
  344. Vue.component('spaceDatetimePicker', {
  345. data: function () {
  346. return {
  347. id: "spaceDatetimePicker" + space.utils.random(6),
  348. showDatetimePickerFlag: false,
  349. defalutFormat: 'YYYY-MM-DD HH:mm:ss',
  350. txt: '',
  351. currentDate: new Date(),
  352. minDate: new Date(1998, 0, 1), //可选的最小时间范围
  353. }
  354. },
  355. name: "spaceDatetimePicker",
  356. props: ["name", "value", "label", "type", "typeflag", "rules"],
  357. created: function () {
  358. },
  359. mounted: function () {
  360. if (space.utils.isNull(this.value)) {
  361. $("#" + this.id).find("div.van-field__right-icon").hide();
  362. }
  363. else {
  364. // 解决iOS时间格式问题
  365. if (this.value.endsWith(".0")) {
  366. this.value = this.value.substring(0, this.value.lastIndexOf(".0"));
  367. }
  368. this.currentDate = new Date(this.value.replace(/-/g, '/'));
  369. this.txt = this.formatTime(this.currentDate, this.getTypeTimeFormat());
  370. this.$emit("input", this.formatTime(this.currentDate, this.defalutFormat));
  371. $("#" + this.id).find("div.van-field__right-icon").show();
  372. }
  373. if (this.type == "time" && !this.value) {
  374. this.currentDate = new Date();
  375. this.currentDate = this.formatTime(this.currentDate, this.getTypeTimeFormat());
  376. }
  377. },
  378. watch: {
  379. value: function (newVal, oldVal) {
  380. var valIsNullFlag = space.utils.isNull(newVal);
  381. if (valIsNullFlag) {
  382. $("#" + this.id).find("div.van-field__right-icon").hide();
  383. } else {
  384. $("#" + this.id).find("div.van-field__right-icon").show();
  385. }
  386. this.txt = valIsNullFlag ? "" : this.getTxtValue(newVal);
  387. // 如果只选择年份
  388. if (this.type == "year-month" && this.typeflag == "year") {
  389. this.txt = this.txt.slice(0, this.txt.indexOf("-"))
  390. }
  391. // 如果选择月日时分,没有年份
  392. if (this.type == "datetime" && this.typeflag == "noyear") {
  393. this.txt = this.txt.slice(this.txt.indexOf("-") + 1, this.txt.length);
  394. }
  395. if (this.type == "time") {
  396. this.currentDate = new Date(this.value.replace(/-/g, '/'));
  397. this.currentDate = this.formatTime(this.currentDate, this.getTypeTimeFormat());
  398. }
  399. }
  400. },
  401. methods: {
  402. showClick: function () {
  403. this.showDatetimePickerFlag = true;
  404. this.$nextTick(function () {
  405. // DOM 更新了
  406. if (this.typeflag == "year") { // 如果只选择年份,去掉HTML元素
  407. $(this.$refs.datetimePicker.$el).find(".van-picker-column").last().hide();
  408. } else if (this.typeflag == "noyear") {
  409. $(this.$refs.datetimePicker.$el).find(".van-picker-column").first().hide();
  410. }
  411. })
  412. },
  413. /**
  414. * 格式化时间
  415. * @param {Object} time
  416. */
  417. formatTime: function (time, format) {
  418. return dayjs(time).format(format);
  419. },
  420. /**
  421. * 选中时间
  422. * @param {Object} time
  423. */
  424. datetimePickerConfirm: function (time) {
  425. if (this.type == "time") {
  426. this.txt = time;
  427. } else if (this.type == "year-month" && this.typeflag == "year") { // 如果只选择年份
  428. this.txt = this.formatTime(time, this.getTypeTimeFormat());
  429. this.txt = this.txt.slice(0, this.txt.indexOf("-"))
  430. } else {
  431. this.txt = this.formatTime(time, this.getTypeTimeFormat());
  432. }
  433. this.showDatetimePickerFlag = false;
  434. this.$emit("input", this.getVModelValue(time));
  435. },
  436. getTxtValue: function (time) {
  437. if (this.type == "time" && time.length <= 5) {
  438. return time;
  439. } else {
  440. return this.formatTime(time, this.getTypeTimeFormat());
  441. }
  442. },
  443. getVModelValue: function (time) {
  444. if (this.type == "time") {
  445. return "2000-01-01 " + time + ":00";
  446. } else {
  447. return this.formatTime(time, this.defalutFormat);
  448. }
  449. },
  450. /**
  451. * 清空
  452. */
  453. fieldClear: function () {
  454. this.txt = "";
  455. this.showDatetimePickerFlag = false;
  456. this.$emit("input", "");
  457. event.stopPropagation();
  458. $("#" + this.id).find("div.van-field__right-icon").hide();
  459. },
  460. getTypeTimeFormat: function () {
  461. if ('date' == this.type) {
  462. return 'YYYY-MM-DD';// 年月日
  463. }
  464. else if ('time' == this.type) {
  465. return 'HH:mm';// 小时和分钟
  466. }
  467. else if ('year-month' == this.type) {
  468. return 'YYYY-MM';// 年月
  469. }
  470. else if ('month-day' == this.type) {
  471. return 'MM-DD';// 月和日
  472. }
  473. else if ('datehour' == this.type) {
  474. return 'YYYY-MM-DD HH';// 年月日时
  475. }
  476. else if ('datetime' == this.type) {
  477. return 'YYYY-MM-DD HH:mm';// 年月日时分
  478. }
  479. }
  480. },
  481. template: `
  482. <div class="component-wrap" :id="id">
  483. <van-field :rules="rules" readonly clickable clearable right-icon="clear" :value="txt" :label="label" :placeholder="'点击选择'+label" @click="showClick" @click-right-icon="fieldClear"></van-field>
  484. <van-popup v-model="showDatetimePickerFlag" position="bottom" get-container="#space-content">
  485. <van-datetime-picker :min-date="minDate" v-model="currentDate" :type="type" :title="'选择'+label" @confirm="datetimePickerConfirm" @cancel="showDatetimePickerFlag = false" ref="datetimePicker"></van-datetime-picker>
  486. </van-popup>
  487. </div>
  488. `
  489. })
  490. /**
  491. * 选择器
  492. * label 有传就是form的显示方式
  493. */
  494. Vue.component('spaceSelect', {
  495. data: function () {
  496. return {
  497. options: [],
  498. isOpen: true, // 是否打开
  499. }
  500. },
  501. name: "spaceSelect",
  502. model: {
  503. prop: 'modelAry',
  504. evnet: 'click'
  505. },
  506. props: ['modelAry', "show", "predefine", "method", "label", "rules", "datasize"],
  507. watch: {
  508. modelAry: function (newVal, oldVal) {
  509. // 没有打开时,则可以初始化选择数据集合
  510. if (!this.isOpen) {
  511. this.isOpen = true;
  512. } else {
  513. this.isOpen = false;
  514. }
  515. }
  516. },
  517. created: function () {
  518. if (this.predefine && this.method) {
  519. space.message.error('predefine 与 method 不能同时存在');
  520. }
  521. if (!this.isPredefine()) {
  522. if (!this.method) {
  523. space.message.warning('预定义选择器不存在:' + this.predefine);
  524. }
  525. }
  526. },
  527. mounted: function () {
  528. this.initSelectedDataList();
  529. },
  530. methods: {
  531. /**
  532. * 获取最大限制绑定的值
  533. */
  534. getMaxSelectedModelAry: function () {
  535. var tmpAry = [];
  536. var _this = this;
  537. this.options.forEach(function (item) {
  538. tmpAry.push(item);
  539. });
  540. if (this.datasize == undefined || this.datasize == 1) {
  541. return tmpAry.length > 0 ? [tmpAry[tmpAry.length - 1]] : [];
  542. } else if (this.datasize > 1) {
  543. var selectedAry = [];
  544. tmpAry.forEach(function (item, index) {
  545. if ((index + 1) > _this.datasize) {
  546. return;
  547. }
  548. selectedAry.push(item);
  549. });
  550. return selectedAry;
  551. } else if (this.datasize == '*') {
  552. return tmpAry;
  553. } else {
  554. return [];
  555. }
  556. },
  557. /**
  558. * 是否预定义选择器,false:不是预定义选择器,true:是预定义选择器
  559. */
  560. isPredefine: function () {
  561. if (this.predefine != "person" && this.predefine != "department" && this.predefine != "post" && this.predefine != "role") {
  562. return false; // 不是预定义选择器
  563. } else {
  564. return true; // 预定义选择器
  565. }
  566. },
  567. /**
  568. * 获取预定义的服务
  569. */
  570. getPredefineService: function () {
  571. var map = new Map();
  572. map.set("person", "/apps?ark=personnel.person_getChoolsePersonInfoApi");
  573. map.set("department", "/apps?ark=sys.department_getChoolseDepartmentInfoApi");
  574. map.set("post", "/apps?ark=sys.post_getChoolsePostInfoApi");
  575. map.set("role", "/apps?ark=sys.role_getChoolseRoleInfoApi");
  576. return map.get(this.predefine);
  577. },
  578. /**
  579. * 初始化选择数据集合
  580. */
  581. initSelectedDataList: function () {
  582. if (!this.isPredefine() || this.method) {
  583. return;
  584. }
  585. if (!this.modelAry || this.modelAry.length == 0) {
  586. this.isOpen = false; // 没有数据时,则关闭
  587. return;
  588. }
  589. var url = this.getPredefineService();
  590. var ids = typeof (this.modelAry) == 'string' || typeof (this.modelAry) == 'number' ? this.modelAry : this.modelAry.join(',');
  591. var _this = this;
  592. // 查询选中的列表
  593. space.utils.ajax({
  594. url: url,
  595. data: {
  596. "ids": ids
  597. },
  598. dataType: 'json',
  599. callback: function (data) {
  600. _this.options = data.data;
  601. var tmpAry = _this.getMaxSelectedModelAry();
  602. _this.$emit("input", tmpAry);
  603. }
  604. })
  605. },
  606. // v-model数组合并去重
  607. uniqFun: function (valueAry) {
  608. var that = this;
  609. // 数组合并
  610. that.modelAry = that.modelAry.concat(valueAry);
  611. var newJson = []; //盛放去重后数据的新数组
  612. for (var item1 of that.modelAry) { //循环json数组对象的内容
  613. var flag = true; //建立标记,判断数据是否重复,true为不重复
  614. for (var item2 of newJson) { //循环新数组的内容
  615. if (item1.id == item2.id) { //让json数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  616. flag = false;
  617. }
  618. }
  619. if (flag) { //判断是否重复
  620. newJson.push(item1); //不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  621. }
  622. }
  623. that.$emit("input", newJson);
  624. },
  625. predefineFun: function () {
  626. var that = this;
  627. var dataSize2 = that.datasize || "9999";
  628. if (!space.utils.isNumberAsObject(dataSize2)) {
  629. dataSize2 = "9999";
  630. }
  631. if (that.modelAry) {
  632. var choosableSize = parseInt(dataSize2) - that.modelAry.length;
  633. if (choosableSize <= 0) {
  634. space.message.warning("数据已达上限");
  635. return;
  636. }
  637. dataSize2 = choosableSize;
  638. }
  639. if (this.predefine == "person") {
  640. space.topWin.space.plugin.personChoose({
  641. datasize: dataSize2
  642. }, function (valueAry) {
  643. that.uniqFun(valueAry);
  644. });
  645. } else if (this.predefine == "department") {
  646. space.topWin.space.plugin.departmentChoose({
  647. datasize: dataSize2
  648. }, function (valueAry) {
  649. that.uniqFun(valueAry);
  650. });
  651. } else if (this.predefine == "post") {
  652. space.topWin.space.plugin.postChoose({
  653. datasize: dataSize2
  654. }, function (valueAry) {
  655. that.uniqFun(valueAry);
  656. });
  657. } else if (this.predefine == "role") {
  658. space.topWin.space.plugin.roleChoose({
  659. datasize: dataSize2
  660. }, function (valueAry) {
  661. that.uniqFun(valueAry);
  662. });
  663. } else {
  664. space.message.warning('预定义选择器不存在:' + this.predefine);
  665. }
  666. },
  667. removeSingle: function (id) {
  668. this.modelAry = this.modelAry.filter(function (item) {
  669. return item.id != id;
  670. })
  671. this.$emit("input", this.modelAry);
  672. },
  673. // 查看全部
  674. checkAll: function () {
  675. var that = this;
  676. space.topWin.space.plugin.layer.open({
  677. url: '/apps?app=sys&destination=plugins.choose_all',
  678. size: 'mini',
  679. anim: 5,
  680. shade: [0.8, '#393D49'],
  681. shadeClose: true,
  682. data: {
  683. selectData: that.modelAry,
  684. show: that.show,
  685. predefine: that.predefine,
  686. method: that.method,
  687. datasize: that.datasize,
  688. // 收到回调
  689. callback: function (data) {
  690. that.$emit("input", data.selectData);
  691. }
  692. }
  693. })
  694. }
  695. },
  696. template: `
  697. <div class="space-select" :class="{'component-wrap': label}">
  698. <van-field :label="label" :rules="rules" :value="modelAry">
  699. <template #input>
  700. <div class="space-select-image" v-if="show == 'image'">
  701. <ul>
  702. <li v-if="modelAry.length > 3" @click="checkAll">
  703. <div class="space-select-image-wrap space-select-all" >
  704. <van-icon name="ellipsis" ></van-icon>
  705. </div>
  706. <p>查看全部</p>
  707. </li>
  708. <li v-for="(item,index) in modelAry.slice(0,3)" :key="item.id" @click="removeSingle(item.id)" >
  709. <div class="space-select-image-wrap">
  710. <van-image :src="item.icon">
  711. <template v-slot:error>{{item.name}}</template>
  712. </van-image>
  713. <van-icon name="clear" class="space-select-image-close" @click="removeSingle(item.id)"></van-icon>
  714. </div>
  715. <p>{{item.name}}</p>
  716. </li>
  717. <li class="space-select-image-choice" @click="predefineFun" v-if="predefine" :class="{'hasOther': modelAry.length > 0}">
  718. <div class="space-select-image-wrap">
  719. <van-icon name="plus" ></van-icon>
  720. </div>
  721. </li>
  722. <li class="space-select-image-choice" @click="method" v-if="method" :class="{'hasOther': modelAry.length > 0}">
  723. <div class="space-select-image-wrap">
  724. <van-icon name="plus" ></van-icon>
  725. </div>
  726. </li>
  727. </ul>
  728. </div>
  729. <div class="space-select-tag" v-if="show != 'image'">
  730. <van-tag size="medium" color="#eaf2fd" text-color="#5094f2" v-if="modelAry.length > 1" @click="checkAll">
  731. 全部
  732. </van-tag>
  733. <van-tag closeable size="medium" color="#eaf2fd" text-color="#5094f2" @close="removeSingle(item.id)" v-for="(item,index) in modelAry.slice(0,1)" :key="item.id">
  734. {{item.name}}
  735. </van-tag>
  736. <span class="space-select-tag-choice" @click="predefineFun" v-if="predefine">
  737. <van-icon name="plus" ></van-icon>
  738. 选择
  739. </span>
  740. <span class="space-select-tag-choice" @click="method" v-if="method">
  741. <van-icon name="plus" ></van-icon>
  742. 选择
  743. </span>
  744. </div>
  745. </template>
  746. </van-field>
  747. </div>
  748. `
  749. })
  750. /**
  751. * 底部导航
  752. */
  753. Vue.component('spaceTabbar', {
  754. data: function () {
  755. return {
  756. config: spaceTabbar.config,
  757. tabbarList: spaceTabbar.tabbarList,
  758. backgroundColorVal: "",
  759. }
  760. },
  761. name: "spaceTabbar",
  762. model: {
  763. prop: 'modelVal',
  764. evnet: 'click'
  765. },
  766. props: ['modelVal', "spaceTabbar"],
  767. created: function () {
  768. // 最多支持6个tabbar
  769. if (this.tabbarList.length > 6) {
  770. this.tabbarList = this.tabbarList.slice(0, 6);
  771. console.error("最多支持6个tabbar");
  772. }
  773. // 风格,可选值 “white”(白) 和 “grey”(灰),白色色值为 #ffffff, 灰色色值为 #f9f9f9,应用于整体背景色
  774. if (this.config.style) {
  775. if (this.config.style == "white") {
  776. this.backgroundColorVal = "#ffffff";
  777. } else if (this.config.style == "grey") {
  778. this.backgroundColorVal = "#f9f9f9";
  779. } else {
  780. console.error("风格的可选值为 “white” 和 “grey”");
  781. }
  782. }
  783. },
  784. methods: {
  785. footBarChange: function (url) {
  786. if (space.utils.isNull(url)) {
  787. space.message.warning("Navigation URL is null!");
  788. return;
  789. }
  790. space.plugin.loading.show();
  791. this.$emit("input", space.utils.appendRandom(url));
  792. },
  793. },
  794. template: `
  795. <div class="space-tabbar">
  796. <ul class="space-tabbar-list" :style="{'background-color':backgroundColorVal}">
  797. <li @click="footBarChange(item.url)" v-for="(item,index) in tabbarList" :key="index" v-if="space.utils.isNull(item.filter) || item.filter != 'no'" :style="{'color': modelVal.indexOf(item.url) != -1 ? config.selectedColor : config.color}" :class="item.class">
  798. <div class="space-tabbar-img-wrap">
  799. <img :src="modelVal.indexOf(item.url) != -1 ? item.selectedIconPath : item.iconPath" alt="">
  800. <span class="space-tabbar-dot" v-if="item.dot"></span>
  801. </div>
  802. <p>
  803. {{item.text}}
  804. </p>
  805. </li>
  806. </ul>
  807. </div>
  808. `
  809. })
  810. /**
  811. * 图片上传
  812. */
  813. Vue.component('spaceUploadImg', {
  814. data: function () {
  815. return {
  816. id: "spaceUploadImg" + space.utils.random(6),
  817. newAry: []
  818. }
  819. },
  820. name: "spaceUploadImg",
  821. model: {
  822. prop: 'patharry',
  823. evnet: 'click'
  824. },
  825. /**
  826. * patharry: v-model 绑定的值,非空,字符串数组
  827. * type: 上传按钮的风格,可空,缺省值为 button ,可选值为button / img
  828. * width: 图片裁剪的宽度,可空
  829. * height: 图片裁剪的高度,可空
  830. * maxsize: 最大上传的图片数量,可空,缺省值为1
  831. * tip: 提示语,可空
  832. * color: 图片背景,可空,值的类型与css的color值类型一样
  833. * label: 左侧文本
  834. * rules: 定义表单校验规则
  835. */
  836. props: {
  837. patharry: {
  838. type: Array,
  839. required: true
  840. },
  841. type: {
  842. type: String,
  843. default: "button"
  844. },
  845. width: [String, Number],
  846. height: [String, Number],
  847. maxsize: {
  848. type: [String, Number],
  849. default: 1
  850. },
  851. tip: [String, Number],
  852. color: [String, Number],
  853. label: [String, Number],
  854. rules: Array
  855. },
  856. created: function () {
  857. // 对初始化值进行处理,排除掉空数据
  858. if (!this.patharry) {
  859. this.patharry = [];
  860. }
  861. if (typeof this.patharry == "string") {
  862. if (space.utils.notNull(this.patharry)) {
  863. this.newAry.push(this.patharry);
  864. }
  865. } else {
  866. for (let index = 0; index < this.patharry.length; index++) {
  867. const element = this.patharry[index];
  868. if (space.utils.notNull(element)) {
  869. this.newAry.push(element);
  870. }
  871. }
  872. }
  873. this.$emit("input", this.newAry);
  874. },
  875. mounted: function () {
  876. var that = this;
  877. space.plugin.cropper.init({
  878. el: $("#" + that.id),
  879. photoSize: { // 裁剪的图片大小,会自动计算裁剪比例
  880. width: that.width,
  881. height: that.height
  882. },
  883. show: function (setting) { //打开裁剪框前的回调
  884. setting.photoSize = {
  885. width: that.width,
  886. height: that.height
  887. }
  888. },
  889. success: function (path) { // 成功后的回调方法,path为裁剪后的img路径
  890. that.newAry.push(path);
  891. that.$emit("input", that.newAry);
  892. },
  893. });
  894. },
  895. methods: {
  896. uploadClick: function () {
  897. if (this.newAry.length >= this.maxsize) {
  898. space.message.warning("最多上传" + this.maxsize + "张图片");
  899. return false;
  900. }
  901. $("#" + this.id).click();
  902. },
  903. removeCropperImg: function (index) {
  904. this.newAry.splice(index, 1);
  905. this.$emit("input", this.newAry);
  906. },
  907. imgPreview: function (index) { //大图预览
  908. var that = this;
  909. vant.ImagePreview({
  910. images: that.newAry,
  911. startPosition: index,
  912. });
  913. }
  914. },
  915. template: `
  916. <div class="space-upload-img" :class="{'component-wrap': label}">
  917. <van-field :label="label" :rules="rules" :value="newAry">
  918. <template #input>
  919. <van-button icon="upgrade" native-type="button" type="default" size="small" @click="uploadClick" :disabled="newAry.length >= maxsize" v-if="type == 'button'">上传</van-button>
  920. <span v-show="newAry.length >= maxsize" style="color: #C0C4CC;margin-left: 6px;">
  921. 最多上传{{maxsize}}张图片
  922. </span>
  923. <span v-show="tip" style="color: #888;margin-left: 6px;">
  924. {{tip}}
  925. </span>
  926. <input type="file" accept="image/*" :id="id" style="display: none;" />
  927. <div class="cropper-img-wrap">
  928. <div v-show="newAry" class="cropper-img-content" v-for="(item, index) in newAry" :key="index"">
  929. <van-image width="80" height="80" fit="contain" :style="{'background-color': color}"
  930. :src="item" @click="imgPreview(index)">
  931. <template v-slot:error>加载失败</template>
  932. </van-image>
  933. <div class="cropper-preview-delete">
  934. <van-icon name="cross" @click="removeCropperImg(index)"></van-icon>
  935. </div>
  936. </div>
  937. <div class="uploadButton-img" v-if="type == 'img'" @click="uploadClick" v-show="newAry.length < maxsize">
  938. <van-icon name="photograph"></van-icon>
  939. </div>
  940. </div>
  941. </template>
  942. </van-field>
  943. </div>
  944. `
  945. })
  946. /**
  947. * 图片预览
  948. */
  949. Vue.component('spacePreviewImg', {
  950. data: function () {
  951. return {
  952. newAry: [],
  953. }
  954. },
  955. name: "spacePreviewImg",
  956. /**
  957. * paths: 绑定的值,非空,字符串/数组
  958. * color: 图片背景色,可空,值的类型与css的color值类型一样
  959. */
  960. props: {
  961. paths: {
  962. type: [Array, String],
  963. required: true
  964. },
  965. color: {
  966. type: String,
  967. },
  968. cell: {
  969. type: String,
  970. default: 'false',
  971. },
  972. label: [String, Number]
  973. },
  974. created: function () {
  975. this.initNewAry();
  976. },
  977. watch: {
  978. paths: function (newVal, oldVal) {
  979. this.initNewAry();
  980. },
  981. },
  982. methods: {
  983. imgPreview: function (index) { //大图预览
  984. var that = this;
  985. space.topWin.vant.ImagePreview({
  986. images: that.newAry,
  987. startPosition: index,
  988. });
  989. },
  990. initNewAry: function () {
  991. // 对初始化值进行处理,排除掉空数据
  992. if (!this.paths) {
  993. this.paths = [];
  994. }
  995. this.newAry = [];
  996. if (typeof this.paths == "string") {
  997. if (space.utils.notNull(this.paths)) {
  998. this.newAry.push(this.paths);
  999. }
  1000. } else {
  1001. for (let index = 0; index < this.paths.length; index++) {
  1002. const element = this.paths[index];
  1003. if (space.utils.notNull(element)) {
  1004. this.newAry.push(element);
  1005. }
  1006. }
  1007. }
  1008. this.$emit("input", this.newAry);
  1009. }
  1010. },
  1011. template: `
  1012. <van-cell v-if="cell == 'true'" :title="label" size="large">
  1013. <template #right-icon>
  1014. <div class="van-cell__value">
  1015. <div class="space-preview-img" style="flex:1.2;" >
  1016. <div class="cropper-img-content" v-for="(item, index) in newAry" :key="index">
  1017. <van-image width="80" height="80" fit="contain" :style="{'background-color': color}"
  1018. :src="item" @click="imgPreview(index)">
  1019. <template v-slot:error>加载失败</template>
  1020. </van-image>
  1021. </div>
  1022. </div>
  1023. </div>
  1024. </template>
  1025. </van-cell>
  1026. <div v-else class="space-preview-img" style="margin-left:12px">
  1027. <div class="cropper-img-content" v-for="(item, index) in newAry" :key="index">
  1028. <van-image width="80" height="80" fit="contain" :style="{'background-color': color}"
  1029. :src="item" @click="imgPreview(index)">
  1030. <template v-slot:error>加载失败</template>
  1031. </van-image>
  1032. </div>
  1033. </div>
  1034. `
  1035. })
  1036. /**
  1037. * Editor 编辑器
  1038. */
  1039. Vue.component('spaceEditor', {
  1040. data: function () {
  1041. return {
  1042. id: "spaceEditor" + space.utils.random(6),
  1043. editor: undefined,
  1044. isSetData: true, // 是否可设置数据
  1045. // 编辑器需要的 js 文件
  1046. jsUrl: [
  1047. '/apps/space/plug-in/ckeditor5/build/ckeditor.js',
  1048. '/apps/space/plug-in/ckeditor5/src/plugins/upload/src/myUploadAdapter.js'
  1049. ],
  1050. // 标识,全部为 true 则代表全部加载完成
  1051. jsUrlFlag: [],
  1052. notLoadEditor: true, // 未加载完 editor 编辑器,true:未加载完,false:已加载完
  1053. }
  1054. },
  1055. name: "spaceEditor",
  1056. model: {
  1057. prop: 'htmlContent',
  1058. evnet: 'click'
  1059. },
  1060. /**
  1061. * htmlContent: v-model 绑定的值,非空,html 字符串
  1062. * size: 编辑器的大小,small、medium、large
  1063. * width: 编辑器的宽度,可空
  1064. * height: 编辑器的高度,可空
  1065. * placeholder:占位符
  1066. * type:编辑器工具栏类型
  1067. * isfullscreen:是否有全屏,
  1068. */
  1069. props: ['htmlContent', 'size', 'width', 'height', 'placeholder', 'type', 'isfullscreen'],
  1070. watch: {
  1071. height: function (newVal, oldVal) {
  1072. if (this.height && this.height.toString().toLocaleLowerCase().indexOf('px') == -1) {
  1073. this.height += 'px';
  1074. }
  1075. else {
  1076. this.setEditorHeight();
  1077. }
  1078. },
  1079. editor: function (newVal, oldVal) {
  1080. this.setEditorHeight();
  1081. },
  1082. jsUrlFlag: function (newVal, oldVal) {
  1083. if (this.jsUrl.length > 0 && this.jsUrl.length == this.jsUrlFlag.length) {
  1084. if (this.jsUrlFlag.indexOf('false') != -1) {
  1085. return;
  1086. }
  1087. this.initEditor();
  1088. this.notLoadEditor = false;
  1089. this.setEditorHeight();
  1090. }
  1091. },
  1092. notLoadEditor: function (newVal, oldVal) {
  1093. this.setEditorHeight();
  1094. },
  1095. },
  1096. created: function () {
  1097. var _this = this;
  1098. for (var i = 0; i < _this.jsUrl.length; i++) {
  1099. _this.loadJS(_this.jsUrl[i], function () {
  1100. _this.jsUrlFlag.push('true');
  1101. });
  1102. }
  1103. },
  1104. methods: {
  1105. loadJS: function (url, callback) {
  1106. for (var i = 0; i < document.getElementsByTagName('head')[0].getElementsByTagName('script').length; i++) {
  1107. var src = document.getElementsByTagName('head')[0].getElementsByTagName('script')[i].getAttribute('src');
  1108. if (url == src) {
  1109. // 防止一个页面有多个编辑器时,编辑器加载失败
  1110. if (space.vars.editorReady != true) {
  1111. var winInterval = setInterval(function () {
  1112. if (space.vars.editorReady != true) {
  1113. return;
  1114. }
  1115. window.clearInterval(winInterval);
  1116. if (callback) {
  1117. callback();
  1118. }
  1119. }, 100)
  1120. }
  1121. return;
  1122. }
  1123. }
  1124. var script = document.createElement('script');
  1125. script.type = 'text/javascript';
  1126. script.onload = function () {
  1127. if (callback) {
  1128. callback();
  1129. }
  1130. };
  1131. script.src = url;
  1132. document.getElementsByTagName('head')[0].appendChild(script);
  1133. },
  1134. myCustomUploadAdapterPlugin: function (editor) {
  1135. editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
  1136. // 第二个参数设置上传图片的地址
  1137. return new MyUploadAdapter(loader);
  1138. };
  1139. },
  1140. /**
  1141. * 获取高度
  1142. */
  1143. getHeight: function () {
  1144. if (!this.height) {
  1145. if (this.size == undefined || this.size == "small") {
  1146. return '200px';
  1147. }
  1148. else if (this.size == "medium") {
  1149. return '400px';
  1150. }
  1151. else if (this.size == "large") {
  1152. return '600px';
  1153. }
  1154. }
  1155. else if (this.height) {
  1156. if (this.height.toString().toLocaleLowerCase().indexOf('px') == -1) {
  1157. return this.height + 'px';
  1158. }
  1159. else {
  1160. return this.height;
  1161. }
  1162. }
  1163. return "";
  1164. },
  1165. /**
  1166. * 设置编辑器高度
  1167. */
  1168. setEditorHeight: function () {
  1169. if (this.notLoadEditor) {
  1170. return;
  1171. }
  1172. var height = this.getHeight();
  1173. if (!this.editor || !height) {
  1174. return;
  1175. }
  1176. var _this = this;
  1177. // 设置编辑器高度
  1178. _this.editor.editing.view.change(writer => {
  1179. writer.setStyle(
  1180. "height",
  1181. height,
  1182. _this.editor.editing.view.document.getRoot()
  1183. );
  1184. });
  1185. },
  1186. /**
  1187. * 获取工具栏
  1188. */
  1189. getToolbar: function () {
  1190. var toolbar = {
  1191. items: ['fontsize', 'fontColor', 'bold', 'italic', 'phrase']
  1192. };
  1193. if (!this.type) {
  1194. return toolbar;
  1195. }
  1196. var map = new Map();
  1197. map.set("flow", ['phrase']);
  1198. if (map.get(this.type)) {
  1199. return {
  1200. items: map.get(this.type)
  1201. }
  1202. }
  1203. return toolbar;
  1204. },
  1205. /**
  1206. * 初始化编辑器
  1207. */
  1208. initEditor: function () {
  1209. var toolbar = this.getToolbar();
  1210. var _this = this;
  1211. ClassicEditor.create(document.querySelector("#" + _this.id), {
  1212. extraPlugins: [_this.myCustomUploadAdapterPlugin], // 添加上传适配器
  1213. toolbar: toolbar || {},
  1214. language: 'zh-cn',
  1215. placeholder: _this.placeholder || '',
  1216. }).then(editor => {
  1217. space.vars.editorReady = true;
  1218. _this.editor = editor;
  1219. if (_this.htmlContent != undefined) {
  1220. _this.editor.setData(_this.htmlContent);
  1221. }
  1222. /**
  1223. * 禁止在编辑器内回车事件
  1224. */
  1225. editor.ui.view.element.onkeydown = function (event) {
  1226. // 回车键
  1227. if (event.keyCode == 13) {
  1228. event.stopPropagation();
  1229. return false;
  1230. }
  1231. // tab 转空格
  1232. if (event.keyCode == 9) {
  1233. const model = editor.model;
  1234. model.change(writer => {
  1235. const ele = writer.createElement('span');
  1236. writer.insertText(" ", ele);
  1237. // 一定要 Element
  1238. model.insertContent(ele);
  1239. });
  1240. event.stopPropagation();
  1241. return false;
  1242. }
  1243. };
  1244. // 设置编辑器宽度
  1245. if (_this.width) {
  1246. $(editor.ui.view.element).css({ 'width': _this.width })
  1247. }
  1248. // 监听编辑器的内容变动事件
  1249. editor.model.document.on('change:data', function () {
  1250. _this.$emit("input", editor.getData());
  1251. });
  1252. }).catch(error => {
  1253. console.log(error);
  1254. });
  1255. }
  1256. },
  1257. template: `
  1258. <div :id="id">
  1259. <script type="text/plain"></script>
  1260. </div>
  1261. `
  1262. })
  1263. /**
  1264. * 对象菜单
  1265. */
  1266. Vue.component('spaceMobileTabs', {
  1267. data: function () {
  1268. return {
  1269. isShowPop: false, //弹窗
  1270. activeUrl: "", //当前iframe的src
  1271. isScroll: false, //是否出现横向滚动条
  1272. random: space.utils.random(6),
  1273. }
  1274. },
  1275. name: "spaceMobileTabs",
  1276. model: {
  1277. prop: 'modelObj',
  1278. evnet: 'click'
  1279. },
  1280. props: ['modelObj'],
  1281. created: function () {
  1282. var that = this;
  1283. space.topWin.layer.load(2);
  1284. var index = that.modelObj.length;
  1285. while (index--) {
  1286. const element = that.modelObj[index];
  1287. // 过滤掉
  1288. if (space.utils.notNull(element.filter) && element.filter == 'no') {
  1289. that.modelObj.splice(index, 1);
  1290. continue;
  1291. }
  1292. }
  1293. if (that.modelObj.length == 0) {
  1294. space.topWin.space.message.warning("你无权访问此页面");
  1295. space.utils.window.close();
  1296. return;
  1297. }
  1298. //没有active,默认选中第一个
  1299. that.activeUrl = that.modelObj[0].url;
  1300. // 有active,选中active项
  1301. that.modelObj.forEach(function (item, index) {
  1302. if (item.active) {
  1303. that.activeUrl = item.url;
  1304. }
  1305. })
  1306. },
  1307. mounted: function () {
  1308. // DOM 更新了
  1309. this.$nextTick(function () {
  1310. // 是否出现滚动条
  1311. this.isScroll = $(this.$refs.spaceMobileTabsWrap).find(".van-tabs__wrap").hasClass("van-tabs__wrap--scrollable");
  1312. })
  1313. space.vars.isMobileTabs = true;
  1314. },
  1315. methods: {
  1316. clickFun: function (url, title) {
  1317. this.activeUrl = url;
  1318. this.isShowPop = false;
  1319. this.random = space.utils.random(6);
  1320. },
  1321. },
  1322. template: `
  1323. <div class="space-mobile-tabs">
  1324. <div class="space-mobile-tabs-list" ref="spaceMobileTabsWrap">
  1325. <van-tabs v-model="activeUrl" color="#1989fa" @click="clickFun">
  1326. <van-tab :title="item.label" v-for="(item, index) in modelObj" :name="item.url" ></van-tab>
  1327. </van-tabs>
  1328. <p v-if="isScroll">
  1329. <van-icon class="space-mobile-tabs-icon" name="wap-nav" @click="isShowPop = true;"></van-icon>
  1330. </p>
  1331. <van-popup v-model="isShowPop" position="top" :style="{ height: '40%' }">
  1332. <ul class="space-mobile-tabs-popList">
  1333. <li :class="{'active': activeUrl == item.url}" v-for="(item, index) in modelObj" @click="clickFun(item.url, index)" >
  1334. {{item.label}}
  1335. </li>
  1336. </ul>
  1337. </van-popup>
  1338. </div>
  1339. <div class="space-mobile-tabs-iframe">
  1340. <iframe :src="activeUrl + '&rn=' + random" frameborder="0"></iframe>
  1341. </div>
  1342. </div>
  1343. `
  1344. })
  1345. /**
  1346. * CMS
  1347. */
  1348. Vue.component('spaceCms', {
  1349. data: function () {
  1350. return {
  1351. fileCount: 0, // 文件总数
  1352. }
  1353. },
  1354. name: "spaceCms",
  1355. model: {
  1356. prop: 'cmsid',
  1357. evnet: 'click'
  1358. },
  1359. props: {
  1360. // v-model
  1361. cmsid: {
  1362. type: [String],
  1363. required: true
  1364. },
  1365. // 文件类型
  1366. accept: {
  1367. type: String
  1368. },
  1369. // 最大上传数量,默认199
  1370. maxsize: {
  1371. type: [String, Number],
  1372. default: 199
  1373. },
  1374. // 左侧文本
  1375. label: String,
  1376. // 定义表单校验规则
  1377. rules: Array
  1378. },
  1379. created: function () {
  1380. this.getCmsFileCount(this.cmsid);
  1381. },
  1382. watch: {
  1383. cmsid: function (newVal, oldVal) {
  1384. this.getCmsFileCount(newVal);
  1385. }
  1386. },
  1387. methods: {
  1388. open: function () {
  1389. space.plugin.cms.openCMS({
  1390. "cmsid": this.cmsid,
  1391. "accept": this.accept,
  1392. "maxsize": this.maxsize
  1393. }, this.callback);
  1394. },
  1395. callback: function (data) {
  1396. this.$emit("input", data.cmsid);
  1397. this.cmsid = data.cmsid;
  1398. this.fileCount = data.fileCount;
  1399. },
  1400. getCmsFileCount: function (cmsid) {
  1401. if (space.utils.isNull(cmsid)) {
  1402. return;
  1403. }
  1404. var that = this;
  1405. space.utils.ajax({
  1406. loadLayer: false,
  1407. url: '/apps?ark=sys.cms_getCmsInfo',
  1408. data: {
  1409. "idcard": cmsid
  1410. },
  1411. dataType: 'json',
  1412. autoTip: false,
  1413. async: false, // 同步请求
  1414. callback: function (data) {
  1415. if (data.code == "success") {
  1416. that.fileCount = data.data.filecount;
  1417. }
  1418. }
  1419. });
  1420. }
  1421. },
  1422. template: `
  1423. <div class="space-upload-CMS" :class="{'component-wrap': label}">
  1424. <van-field :label="label" :rules="rules" :value="cmsid">
  1425. <template #input>
  1426. <van-badge :content="fileCount" v-show="fileCount > 0" color="#1989fa">
  1427. <van-button icon="upgrade" native-type="button" type="default" size="small" @click="open">上传文件</van-button>
  1428. </van-badge>
  1429. <van-button icon="upgrade" native-type="button" type="default" size="small" @click="open" v-show="fileCount == 0">上传文件</van-button>
  1430. </template>
  1431. </van-field>
  1432. </div>`
  1433. })
  1434. /**
  1435. * CMS预览
  1436. * 有传label就是左侧有文本的cell信息格式,不传则不是
  1437. */
  1438. Vue.component('spaceCmsView', {
  1439. data: function () {
  1440. return {
  1441. thumbnail: "", //thumbnail: 缩略图
  1442. filename: "", //filename: 文件名
  1443. filecount: 0, //filecount: 文件数
  1444. isShowEl: true, //是否显示整个组件元素
  1445. }
  1446. },
  1447. name: "spaceCmsView",
  1448. /**
  1449. * cmsid: 绑定的值,非空
  1450. * label: 左侧文本
  1451. */
  1452. props: {
  1453. cmsid: {
  1454. type: [String, Number],
  1455. required: true
  1456. },
  1457. label: String
  1458. },
  1459. created: function () {
  1460. var that = this;
  1461. if (space.utils.isNull(that.cmsid)) {
  1462. // 不显示整个组件元素
  1463. that.isShowEl = false;
  1464. return;
  1465. }
  1466. space.utils.ajax({
  1467. loadLayer: false,
  1468. url: '/apps?ark=sys.cms_getCmsInfo',
  1469. data: {
  1470. "idcard": that.cmsid
  1471. },
  1472. dataType: 'json',
  1473. autoTip: false,
  1474. async: false, // 同步请求
  1475. callback: function (data) {
  1476. if (data.code == "success") {
  1477. that.thumbnail = data.data.thumbnail;
  1478. that.filename = data.data.filename;
  1479. that.filecount = data.data.filecount;
  1480. } else if (data.code == "warning") {
  1481. // 不显示整个组件元素
  1482. that.isShowEl = false;
  1483. }
  1484. }
  1485. });
  1486. },
  1487. methods: {
  1488. open: function () {
  1489. var that = this;
  1490. space.plugin.cms.openCMSView({
  1491. cmsid: that.cmsid
  1492. })
  1493. },
  1494. },
  1495. template: `
  1496. <van-cell v-if="label" :title="label" size="large">
  1497. <template #right-icon>
  1498. <div class="van-cell__value">
  1499. <div class="space-cms-view" v-if="isShowEl">
  1500. <div class="space-cms-view-wrap" @click="open">
  1501. <div class="space-cms-view-main">
  1502. <van-image fit="contain" :src="thumbnail""></van-image>
  1503. <span>{{filename}}</span>
  1504. </div>
  1505. <div v-show="filecount >=2 " class="more-file"></div>
  1506. <div v-show="filecount >=2 " class="more-file more-file-bottom"></div>
  1507. </div>
  1508. </div>
  1509. </div>
  1510. </template>
  1511. </van-cell>
  1512. <div class="space-cms-view" v-else >
  1513. <div class="space-cms-view-wrap" @click="open" v-if="isShowEl" >
  1514. <div class="space-cms-view-main">
  1515. <van-image fit="contain" :src="thumbnail""></van-image>
  1516. <span>{{filename}}</span>
  1517. <span v-if="filecount==0">(空)</span>
  1518. </div>
  1519. <div v-show="filecount >=2 " class="more-file"></div>
  1520. <div v-show="filecount >=2 " class="more-file more-file-bottom"></div>
  1521. </div>
  1522. </div>
  1523. `
  1524. })
  1525. /**
  1526. * 对象选择器内容
  1527. */
  1528. Vue.component('spaceObjectSelectContent', {
  1529. data: function () {
  1530. return {
  1531. dataList: [], // 数据
  1532. selectResult: [], //选中的数据
  1533. isShowPop: false, //底部弹窗开关
  1534. }
  1535. },
  1536. name: "spaceObjectSelectContent",
  1537. model: {
  1538. prop: 'selectDataList',
  1539. evnet: 'click'
  1540. },
  1541. /**
  1542. * selectDataList: v-model,绑定的值, 已选数组
  1543. * url: 数据源对象
  1544. * filter: 过滤条件对象
  1545. * maxsize: 最大选择数量,如未声明,则默认为1,如已选数组已超过最大选择数量,则按照数组顺序截取
  1546. * confirm: 事件参数,当点击了已选区域的“确定”按钮时,触发此事件
  1547. */
  1548. props: {
  1549. selectDataList: {
  1550. type: Array,
  1551. required: true
  1552. },
  1553. url: {
  1554. type: String
  1555. },
  1556. filter: {
  1557. type: Object
  1558. },
  1559. mapping: {
  1560. type: Object
  1561. },
  1562. maxsize: {
  1563. type: [String, Number],
  1564. default: 1
  1565. },
  1566. confirm: {
  1567. type: Function
  1568. }
  1569. },
  1570. created: function () {
  1571. this.initMapping();
  1572. },
  1573. mounted: function () {
  1574. var that = this;
  1575. space.plugin.paging.init({
  1576. url: that.url,
  1577. data: that.filter,
  1578. up: function (resp) {
  1579. that.dataList.push.apply(that.dataList, resp[that.mapping.data]);
  1580. },
  1581. down: function () {
  1582. that.dataList = [];
  1583. },
  1584. });
  1585. },
  1586. methods: {
  1587. // 选中点击事件
  1588. checkboxClick: function (id) {
  1589. var that = this;
  1590. // if (this.selectResult.length == this.maxsize) {
  1591. // this.$toast('最多选择' + this.maxsize + "项");
  1592. // }
  1593. if (this.selectResult.indexOf(id) > -1) {
  1594. that.selectDataList = [];
  1595. that.selectResult.forEach(function (item) {
  1596. that.dataList.forEach(function (dataItem) {
  1597. if (item == dataItem[that.mapping.id]) {
  1598. that.selectDataList.indexOf(dataItem) > -1 ? "" : that.selectDataList.push(dataItem);
  1599. }
  1600. })
  1601. })
  1602. } else {
  1603. this.selectDataList = this.selectDataList.filter(function (item) {
  1604. return item[that.mapping.id] != id;
  1605. })
  1606. }
  1607. this.$emit("input", this.selectDataList);
  1608. },
  1609. initMapping: function () {
  1610. if (!this.mapping) {
  1611. this.mapping = {};
  1612. }
  1613. if (space.utils.isNull(this.mapping.data)) {
  1614. this.mapping.data = "data";
  1615. }
  1616. if (space.utils.isNull(this.mapping.id)) {
  1617. this.mapping.id = "id";
  1618. }
  1619. if (space.utils.isNull(this.mapping.icon)) {
  1620. this.mapping.icon = "icon";
  1621. }
  1622. if (space.utils.isNull(this.mapping.name)) {
  1623. this.mapping.name = "name";
  1624. }
  1625. if (space.utils.isNull(this.mapping.tag)) {
  1626. this.mapping.tag = "tag";
  1627. }
  1628. },
  1629. mappingResult: function (data) {
  1630. var newDataAry = [];
  1631. for (let index = 0; index < data.length; index++) {
  1632. const element = data[index];
  1633. var newEle = {};
  1634. newEle["id"] = ("id" in element) ? element.id : element[this.mapping.id];
  1635. newEle["icon"] = ("icon" in element) ? element.icon : element[this.mapping.icon];
  1636. newEle["name"] = ("name" in element) ? element.name : element[this.mapping.name];
  1637. newEle["tag"] = ("tag" in element) ? element.tag : element[this.mapping.tag];
  1638. newDataAry[index] = newEle;
  1639. }
  1640. return newDataAry;
  1641. },
  1642. // 初始化选中的数据
  1643. initSelectDataList: function () {
  1644. var that = this;
  1645. // 反向映射
  1646. var newDataAry = [];
  1647. for (let index = 0; index < that.selectDataList.length; index++) {
  1648. const element = that.selectDataList[index];
  1649. var newEle = {};
  1650. newEle[this.mapping.id] = ("id" in element) ? element.id : element[this.mapping.id];
  1651. newEle[this.mapping.icon] = ("icon" in element) ? element.icon : element[this.mapping.icon];
  1652. newEle[this.mapping.name] = ("name" in element) ? element.name : element[this.mapping.name];
  1653. newEle[this.mapping.tag] = ("tag" in element) ? element.tag : element[this.mapping.tag];
  1654. newDataAry[index] = newEle;
  1655. }
  1656. that.selectDataList = newDataAry; // 重新赋值
  1657. that.selectDataList.forEach(function (item) {
  1658. that.selectResult.push(item[that.mapping.id]);
  1659. });
  1660. //如已选数组已超过最大选择数量,则按照数组顺序截取
  1661. if (that.selectResult.length > that.maxsize) {
  1662. that.selectResult = that.selectResult.slice(0, that.maxsize);
  1663. that.selectDataList = that.selectDataList.slice(0, that.maxsize);
  1664. }
  1665. this.$emit("input", this.selectDataList);
  1666. },
  1667. isShowPopClick: function () {
  1668. // 没有已选,不弹弹窗
  1669. this.isShowPop = this.selectDataList.length <= 0 ? false : !this.isShowPop;
  1670. },
  1671. // 删除
  1672. removeSelect: function (id) {
  1673. var that = this;
  1674. this.selectResult.splice(this.selectResult.indexOf(id), 1);
  1675. this.selectDataList = this.selectDataList.filter(function (item) {
  1676. return item[that.mapping.id] != id;
  1677. })
  1678. if (this.selectResult <= 0) {
  1679. this.isShowPop = false;
  1680. }
  1681. this.$emit("input", this.selectDataList);
  1682. },
  1683. confirmEvent: function () {
  1684. this.confirm(this.mappingResult(this.selectDataList));
  1685. }
  1686. },
  1687. template: `
  1688. <div class="space-object-select-content">
  1689. <div class="obj-select-list">
  1690. <div id="mescroll" class="mescroll importantMescroll">
  1691. <van-checkbox-group v-model="selectResult" :max="maxsize">
  1692. <van-checkbox v-for="item in dataList" :key="item[mapping.id]" :name="item[mapping.id]" shape="square" @click="checkboxClick(item[mapping.id])" >
  1693. <!-- 左边 -->
  1694. <div class="contacts-list-left">
  1695. <van-image :src="item[mapping.icon]" v-show="item[mapping.icon]">
  1696. <template v-slot:error>
  1697. <van-icon name="user-o"></van-icon>
  1698. </template>
  1699. </van-image>
  1700. </div>
  1701. <!-- 右边 -->
  1702. <div class="contacts-list-right">
  1703. <div class="contacts-list-title">
  1704. {{item[mapping.name]}}
  1705. </div>
  1706. <div class="contacts-list-desc">
  1707. <p>
  1708. <span>
  1709. {{item[mapping.tag]}}
  1710. </span>
  1711. </p>
  1712. </div>
  1713. </div>
  1714. </van-checkbox>
  1715. </van-checkbox-group>
  1716. </div>
  1717. </div>
  1718. <div class="obj-select-footer" @click="isShowPopClick">
  1719. 已选
  1720. <span class="obj-select-count">
  1721. {{selectResult.length}}
  1722. </span>
  1723. / {{maxsize}}
  1724. 项
  1725. <van-button square type="info" @click.stop="confirmEvent">确定</van-button>
  1726. </div>
  1727. <!-- 底部弹出框 -->
  1728. <van-popup v-model="isShowPop" round position="bottom" :style="{ 'max-height': '85%' }" >
  1729. <div class="obj-selecte-pop">
  1730. <ul>
  1731. <li v-for="item in selectDataList">
  1732. <!-- 左边 -->
  1733. <div class="contacts-list-left">
  1734. <van-image :src="item[mapping.icon]" v-show="item[mapping.icon]">
  1735. <template v-slot:error>
  1736. <van-icon name="user-o"></van-icon>
  1737. </template>
  1738. </van-image>
  1739. </div>
  1740. <!-- 右边 -->
  1741. <div class="contacts-list-right">
  1742. <div class="contacts-list-title">
  1743. {{item[mapping.name]}}
  1744. </div>
  1745. <div class="contacts-list-desc">
  1746. <p>
  1747. <span>
  1748. {{item[mapping.tag]}}
  1749. </span>
  1750. </p>
  1751. </div>
  1752. </div>
  1753. <!-- 删除 -->
  1754. <van-icon name="close" class="obj-remove-icon" @click="removeSelect(item[mapping.id])"></van-icon>
  1755. </li>
  1756. </ul>
  1757. </div>
  1758. </van-popup>
  1759. </div>`
  1760. })
  1761. /**
  1762. * 对象选择器外层
  1763. */
  1764. Vue.component('spaceObjectSelect', {
  1765. data: function () {
  1766. return {
  1767. }
  1768. },
  1769. name: "spaceObjectSelect",
  1770. model: {
  1771. prop: 'selectResult',
  1772. evnet: 'click'
  1773. },
  1774. /**
  1775. * selectResult: v-model,绑定的值, 已选数组
  1776. * maxsize: 最大选择数量,如未声明,则默认为1
  1777. * page: 路径
  1778. * label: 左侧文本
  1779. */
  1780. props: {
  1781. selectResult: {
  1782. type: Array,
  1783. required: true
  1784. },
  1785. maxsize: {
  1786. type: [String, Number],
  1787. default: 1
  1788. },
  1789. translate: {
  1790. type: String
  1791. },
  1792. page: {
  1793. type: String,
  1794. required: true
  1795. },
  1796. mapping: {
  1797. type: Object,
  1798. },
  1799. label: {
  1800. type: String,
  1801. },
  1802. rules: {
  1803. type: Array,
  1804. },
  1805. show: {
  1806. type: String,
  1807. default: "tag"
  1808. },
  1809. },
  1810. created: function () {
  1811. // 初始化映射
  1812. this.initMapping();
  1813. // 需要翻译,但未传入翻译服务
  1814. if (space.utils.notNull(this.selectResult) && space.utils.isNull(this.translate)) {
  1815. console.error("需要翻译已选数组对象,但未传入翻译服务");
  1816. return;
  1817. }
  1818. },
  1819. mounted: function () {
  1820. this.translateSelect();
  1821. },
  1822. watch: {
  1823. },
  1824. methods: {
  1825. // 初始化映射对象
  1826. initMapping: function () {
  1827. if (!this.mapping) {
  1828. this.mapping = {};
  1829. }
  1830. if (space.utils.isNull(this.mapping.data)) {
  1831. this.mapping.data = "data";
  1832. }
  1833. if (space.utils.isNull(this.mapping.id)) {
  1834. this.mapping.id = "id";
  1835. }
  1836. if (space.utils.isNull(this.mapping.icon)) {
  1837. this.mapping.icon = "icon";
  1838. }
  1839. if (space.utils.isNull(this.mapping.name)) {
  1840. this.mapping.name = "name";
  1841. }
  1842. if (space.utils.isNull(this.mapping.tag)) {
  1843. this.mapping.tag = "tag";
  1844. }
  1845. },
  1846. mappingResult: function (data) {
  1847. for (let index = 0; index < data.length; index++) {
  1848. var element = data[index];
  1849. if (!("id" in element)) {
  1850. element["id"] = element[this.mapping.id];
  1851. }
  1852. if (!("icon" in element)) {
  1853. element["icon"] = element[this.mapping.icon];
  1854. }
  1855. if (!("name" in element)) {
  1856. element["name"] = element[this.mapping.name];
  1857. }
  1858. if (!("tag" in element)) {
  1859. element["tag"] = element[this.mapping.tag];
  1860. }
  1861. }
  1862. return data;
  1863. },
  1864. translateSelect: function () {
  1865. var that = this;
  1866. // 翻译已选内容
  1867. if (space.utils.notNull(that.selectResult)) {
  1868. space.utils.ajax({
  1869. url: that.translate,
  1870. data: {
  1871. ids: that.selectResult.join(",")
  1872. },
  1873. dataType: 'json',
  1874. async: false,
  1875. callback: function (resp) {
  1876. if (resp.code == "success") {
  1877. // 映射字段保持与标准一致
  1878. that.selectResult = that.mappingResult(resp[that.mapping.data]);
  1879. that.$emit("input", that.selectResult);
  1880. }
  1881. }
  1882. })
  1883. }
  1884. },
  1885. open: function () {
  1886. var that = this;
  1887. space.plugin.layer.open({
  1888. url: that.page,
  1889. data: {
  1890. selectResult: that.selectResult,
  1891. maxsize: that.maxsize,
  1892. callback: function (data) { // 回调
  1893. // console.log(data);
  1894. that.selectResult = data;
  1895. that.$emit("input", that.selectResult);
  1896. }
  1897. }
  1898. })
  1899. },
  1900. removeSingle: function (id) {
  1901. this.selectResult = this.selectResult.filter(function (item) {
  1902. return item.id != id;
  1903. })
  1904. this.$emit("input", this.selectResult);
  1905. },
  1906. // 查看全部
  1907. checkAll: function () {
  1908. var that = this;
  1909. space.topWin.space.plugin.layer.open({
  1910. url: '/apps?app=sys&destination=plugins.object_choose_all',
  1911. size: 'mini',
  1912. anim: 5,
  1913. shade: [0.8, '#393D49'],
  1914. shadeClose: true,
  1915. data: {
  1916. page: that.page,
  1917. selectData: that.selectResult,
  1918. show: that.show,
  1919. datasize: that.maxsize,
  1920. callback: function (data, callback2) {
  1921. that.$emit("input", data.selectData);
  1922. if (callback2) {
  1923. callback2();
  1924. }
  1925. }
  1926. }
  1927. })
  1928. }
  1929. },
  1930. template: `
  1931. <div class="space-select space-object-select" :class="{'component-wrap': label}">
  1932. <van-field :label="label" :rules="rules" :value="selectResult">
  1933. <template #input>
  1934. <div class="space-select-image" v-if="show == 'image'">
  1935. <ul>
  1936. <li v-if="selectResult.length > 3" @click="checkAll">
  1937. <div class="space-select-image-wrap space-select-all" >
  1938. <van-icon name="ellipsis" ></van-icon>
  1939. </div>
  1940. <p>查看全部</p>
  1941. </li>
  1942. <li v-for="(item,index) in selectResult.slice(0,3)" :key="item.id" @click="removeSingle(item.id)" >
  1943. <div class="space-select-image-wrap">
  1944. <van-image :src="item.icon">
  1945. <template v-slot:error>{{item.name}}</template>
  1946. </van-image>
  1947. <van-icon name="clear" class="space-select-image-close" @click="removeSingle(item.id)"></van-icon>
  1948. </div>
  1949. <p>{{item.name}}</p>
  1950. </li>
  1951. <li class="space-select-image-choice" @click="open" :class="{'hasOther': selectResult.length > 0}">
  1952. <div class="space-select-image-wrap">
  1953. <van-icon name="plus" ></van-icon>
  1954. </div>
  1955. </li>
  1956. </ul>
  1957. </div>
  1958. <div class="space-select-tag" v-if="show != 'image'">
  1959. <van-tag size="medium" color="#eaf2fd" text-color="#5094f2" v-if="selectResult.length > 1" @click="checkAll">
  1960. 全部
  1961. </van-tag>
  1962. <van-tag closeable size="medium" color="#eaf2fd" text-color="#5094f2" @close="removeSingle(item.id)" v-for="(item,index) in selectResult.slice(0,1)" :key="item.id">
  1963. {{item.name}}
  1964. </van-tag>
  1965. <span class="space-select-tag-choice" @click="open">
  1966. <van-icon name="plus" ></van-icon>
  1967. 选择
  1968. </span>
  1969. </div>
  1970. </template>
  1971. </van-field>
  1972. </div>`
  1973. })