transfer.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "/dist/";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 65);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 0:
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
  93. /* globals __VUE_SSR_CONTEXT__ */
  94. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  95. // This module is a runtime utility for cleaner component module output and will
  96. // be included in the final webpack user bundle.
  97. function normalizeComponent (
  98. scriptExports,
  99. render,
  100. staticRenderFns,
  101. functionalTemplate,
  102. injectStyles,
  103. scopeId,
  104. moduleIdentifier, /* server only */
  105. shadowMode /* vue-cli only */
  106. ) {
  107. // Vue.extend constructor export interop
  108. var options = typeof scriptExports === 'function'
  109. ? scriptExports.options
  110. : scriptExports
  111. // render functions
  112. if (render) {
  113. options.render = render
  114. options.staticRenderFns = staticRenderFns
  115. options._compiled = true
  116. }
  117. // functional template
  118. if (functionalTemplate) {
  119. options.functional = true
  120. }
  121. // scopedId
  122. if (scopeId) {
  123. options._scopeId = 'data-v-' + scopeId
  124. }
  125. var hook
  126. if (moduleIdentifier) { // server build
  127. hook = function (context) {
  128. // 2.3 injection
  129. context =
  130. context || // cached call
  131. (this.$vnode && this.$vnode.ssrContext) || // stateful
  132. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  133. // 2.2 with runInNewContext: true
  134. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  135. context = __VUE_SSR_CONTEXT__
  136. }
  137. // inject component styles
  138. if (injectStyles) {
  139. injectStyles.call(this, context)
  140. }
  141. // register component module identifier for async chunk inferrence
  142. if (context && context._registeredComponents) {
  143. context._registeredComponents.add(moduleIdentifier)
  144. }
  145. }
  146. // used by ssr in case component is cached and beforeCreate
  147. // never gets called
  148. options._ssrRegister = hook
  149. } else if (injectStyles) {
  150. hook = shadowMode
  151. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  152. : injectStyles
  153. }
  154. if (hook) {
  155. if (options.functional) {
  156. // for template-only hot-reload because in that case the render fn doesn't
  157. // go through the normalizer
  158. options._injectStyles = hook
  159. // register for functioal component in vue file
  160. var originalRender = options.render
  161. options.render = function renderWithStyleInjection (h, context) {
  162. hook.call(context)
  163. return originalRender(h, context)
  164. }
  165. } else {
  166. // inject component registration as beforeCreate hook
  167. var existing = options.beforeCreate
  168. options.beforeCreate = existing
  169. ? [].concat(existing, hook)
  170. : [hook]
  171. }
  172. }
  173. return {
  174. exports: scriptExports,
  175. options: options
  176. }
  177. }
  178. /***/ }),
  179. /***/ 10:
  180. /***/ (function(module, exports) {
  181. module.exports = require("element-ui/lib/input");
  182. /***/ }),
  183. /***/ 11:
  184. /***/ (function(module, exports) {
  185. module.exports = require("element-ui/lib/mixins/migrating");
  186. /***/ }),
  187. /***/ 14:
  188. /***/ (function(module, exports) {
  189. module.exports = require("element-ui/lib/button");
  190. /***/ }),
  191. /***/ 19:
  192. /***/ (function(module, exports) {
  193. module.exports = require("element-ui/lib/checkbox");
  194. /***/ }),
  195. /***/ 39:
  196. /***/ (function(module, exports) {
  197. module.exports = require("element-ui/lib/checkbox-group");
  198. /***/ }),
  199. /***/ 4:
  200. /***/ (function(module, exports) {
  201. module.exports = require("element-ui/lib/mixins/emitter");
  202. /***/ }),
  203. /***/ 6:
  204. /***/ (function(module, exports) {
  205. module.exports = require("element-ui/lib/mixins/locale");
  206. /***/ }),
  207. /***/ 65:
  208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  209. "use strict";
  210. __webpack_require__.r(__webpack_exports__);
  211. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/transfer/src/main.vue?vue&type=template&id=5c654dd8&
  212. var render = function() {
  213. var _vm = this
  214. var _h = _vm.$createElement
  215. var _c = _vm._self._c || _h
  216. return _c(
  217. "div",
  218. { staticClass: "el-transfer" },
  219. [
  220. _c(
  221. "transfer-panel",
  222. _vm._b(
  223. {
  224. ref: "leftPanel",
  225. attrs: {
  226. data: _vm.sourceData,
  227. title: _vm.titles[0] || _vm.t("el.transfer.titles.0"),
  228. "default-checked": _vm.leftDefaultChecked,
  229. placeholder:
  230. _vm.filterPlaceholder || _vm.t("el.transfer.filterPlaceholder")
  231. },
  232. on: { "checked-change": _vm.onSourceCheckedChange }
  233. },
  234. "transfer-panel",
  235. _vm.$props,
  236. false
  237. ),
  238. [_vm._t("left-footer")],
  239. 2
  240. ),
  241. _c(
  242. "div",
  243. { staticClass: "el-transfer__buttons" },
  244. [
  245. _c(
  246. "el-button",
  247. {
  248. class: [
  249. "el-transfer__button",
  250. _vm.hasButtonTexts ? "is-with-texts" : ""
  251. ],
  252. attrs: {
  253. type: "primary",
  254. disabled: _vm.rightChecked.length === 0
  255. },
  256. nativeOn: {
  257. click: function($event) {
  258. return _vm.addToLeft($event)
  259. }
  260. }
  261. },
  262. [
  263. _c("i", { staticClass: "el-icon-arrow-left" }),
  264. _vm.buttonTexts[0] !== undefined
  265. ? _c("span", [_vm._v(_vm._s(_vm.buttonTexts[0]))])
  266. : _vm._e()
  267. ]
  268. ),
  269. _c(
  270. "el-button",
  271. {
  272. class: [
  273. "el-transfer__button",
  274. _vm.hasButtonTexts ? "is-with-texts" : ""
  275. ],
  276. attrs: {
  277. type: "primary",
  278. disabled: _vm.leftChecked.length === 0
  279. },
  280. nativeOn: {
  281. click: function($event) {
  282. return _vm.addToRight($event)
  283. }
  284. }
  285. },
  286. [
  287. _vm.buttonTexts[1] !== undefined
  288. ? _c("span", [_vm._v(_vm._s(_vm.buttonTexts[1]))])
  289. : _vm._e(),
  290. _c("i", { staticClass: "el-icon-arrow-right" })
  291. ]
  292. )
  293. ],
  294. 1
  295. ),
  296. _c(
  297. "transfer-panel",
  298. _vm._b(
  299. {
  300. ref: "rightPanel",
  301. attrs: {
  302. data: _vm.targetData,
  303. title: _vm.titles[1] || _vm.t("el.transfer.titles.1"),
  304. "default-checked": _vm.rightDefaultChecked,
  305. placeholder:
  306. _vm.filterPlaceholder || _vm.t("el.transfer.filterPlaceholder")
  307. },
  308. on: { "checked-change": _vm.onTargetCheckedChange }
  309. },
  310. "transfer-panel",
  311. _vm.$props,
  312. false
  313. ),
  314. [_vm._t("right-footer")],
  315. 2
  316. )
  317. ],
  318. 1
  319. )
  320. }
  321. var staticRenderFns = []
  322. render._withStripped = true
  323. // CONCATENATED MODULE: ./packages/transfer/src/main.vue?vue&type=template&id=5c654dd8&
  324. // EXTERNAL MODULE: external "element-ui/lib/button"
  325. var button_ = __webpack_require__(14);
  326. var button_default = /*#__PURE__*/__webpack_require__.n(button_);
  327. // EXTERNAL MODULE: external "element-ui/lib/mixins/emitter"
  328. var emitter_ = __webpack_require__(4);
  329. var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
  330. // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
  331. var locale_ = __webpack_require__(6);
  332. var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
  333. // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/transfer/src/transfer-panel.vue?vue&type=template&id=2ddab8bd&
  334. var transfer_panelvue_type_template_id_2ddab8bd_render = function() {
  335. var _vm = this
  336. var _h = _vm.$createElement
  337. var _c = _vm._self._c || _h
  338. return _c("div", { staticClass: "el-transfer-panel" }, [
  339. _c(
  340. "p",
  341. { staticClass: "el-transfer-panel__header" },
  342. [
  343. _c(
  344. "el-checkbox",
  345. {
  346. attrs: { indeterminate: _vm.isIndeterminate },
  347. on: { change: _vm.handleAllCheckedChange },
  348. model: {
  349. value: _vm.allChecked,
  350. callback: function($$v) {
  351. _vm.allChecked = $$v
  352. },
  353. expression: "allChecked"
  354. }
  355. },
  356. [
  357. _vm._v("\n " + _vm._s(_vm.title) + "\n "),
  358. _c("span", [_vm._v(_vm._s(_vm.checkedSummary))])
  359. ]
  360. )
  361. ],
  362. 1
  363. ),
  364. _c(
  365. "div",
  366. {
  367. class: [
  368. "el-transfer-panel__body",
  369. _vm.hasFooter ? "is-with-footer" : ""
  370. ]
  371. },
  372. [
  373. _vm.filterable
  374. ? _c(
  375. "el-input",
  376. {
  377. staticClass: "el-transfer-panel__filter",
  378. attrs: { size: "small", placeholder: _vm.placeholder },
  379. nativeOn: {
  380. mouseenter: function($event) {
  381. _vm.inputHover = true
  382. },
  383. mouseleave: function($event) {
  384. _vm.inputHover = false
  385. }
  386. },
  387. model: {
  388. value: _vm.query,
  389. callback: function($$v) {
  390. _vm.query = $$v
  391. },
  392. expression: "query"
  393. }
  394. },
  395. [
  396. _c("i", {
  397. class: ["el-input__icon", "el-icon-" + _vm.inputIcon],
  398. attrs: { slot: "prefix" },
  399. on: { click: _vm.clearQuery },
  400. slot: "prefix"
  401. })
  402. ]
  403. )
  404. : _vm._e(),
  405. _c(
  406. "el-checkbox-group",
  407. {
  408. directives: [
  409. {
  410. name: "show",
  411. rawName: "v-show",
  412. value: !_vm.hasNoMatch && _vm.data.length > 0,
  413. expression: "!hasNoMatch && data.length > 0"
  414. }
  415. ],
  416. staticClass: "el-transfer-panel__list",
  417. class: { "is-filterable": _vm.filterable },
  418. model: {
  419. value: _vm.checked,
  420. callback: function($$v) {
  421. _vm.checked = $$v
  422. },
  423. expression: "checked"
  424. }
  425. },
  426. _vm._l(_vm.filteredData, function(item) {
  427. return _c(
  428. "el-checkbox",
  429. {
  430. key: item[_vm.keyProp],
  431. staticClass: "el-transfer-panel__item",
  432. attrs: {
  433. label: item[_vm.keyProp],
  434. disabled: item[_vm.disabledProp]
  435. }
  436. },
  437. [_c("option-content", { attrs: { option: item } })],
  438. 1
  439. )
  440. }),
  441. 1
  442. ),
  443. _c(
  444. "p",
  445. {
  446. directives: [
  447. {
  448. name: "show",
  449. rawName: "v-show",
  450. value: _vm.hasNoMatch,
  451. expression: "hasNoMatch"
  452. }
  453. ],
  454. staticClass: "el-transfer-panel__empty"
  455. },
  456. [_vm._v(_vm._s(_vm.t("el.transfer.noMatch")))]
  457. ),
  458. _c(
  459. "p",
  460. {
  461. directives: [
  462. {
  463. name: "show",
  464. rawName: "v-show",
  465. value: _vm.data.length === 0 && !_vm.hasNoMatch,
  466. expression: "data.length === 0 && !hasNoMatch"
  467. }
  468. ],
  469. staticClass: "el-transfer-panel__empty"
  470. },
  471. [_vm._v(_vm._s(_vm.t("el.transfer.noData")))]
  472. )
  473. ],
  474. 1
  475. ),
  476. _vm.hasFooter
  477. ? _c(
  478. "p",
  479. { staticClass: "el-transfer-panel__footer" },
  480. [_vm._t("default")],
  481. 2
  482. )
  483. : _vm._e()
  484. ])
  485. }
  486. var transfer_panelvue_type_template_id_2ddab8bd_staticRenderFns = []
  487. transfer_panelvue_type_template_id_2ddab8bd_render._withStripped = true
  488. // CONCATENATED MODULE: ./packages/transfer/src/transfer-panel.vue?vue&type=template&id=2ddab8bd&
  489. // EXTERNAL MODULE: external "element-ui/lib/checkbox-group"
  490. var checkbox_group_ = __webpack_require__(39);
  491. var checkbox_group_default = /*#__PURE__*/__webpack_require__.n(checkbox_group_);
  492. // EXTERNAL MODULE: external "element-ui/lib/checkbox"
  493. var checkbox_ = __webpack_require__(19);
  494. var checkbox_default = /*#__PURE__*/__webpack_require__.n(checkbox_);
  495. // EXTERNAL MODULE: external "element-ui/lib/input"
  496. var input_ = __webpack_require__(10);
  497. var input_default = /*#__PURE__*/__webpack_require__.n(input_);
  498. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/transfer/src/transfer-panel.vue?vue&type=script&lang=js&
  499. //
  500. //
  501. //
  502. //
  503. //
  504. //
  505. //
  506. //
  507. //
  508. //
  509. //
  510. //
  511. //
  512. //
  513. //
  514. //
  515. //
  516. //
  517. //
  518. //
  519. //
  520. //
  521. //
  522. //
  523. //
  524. //
  525. //
  526. //
  527. //
  528. //
  529. //
  530. //
  531. //
  532. //
  533. //
  534. //
  535. //
  536. //
  537. //
  538. //
  539. //
  540. //
  541. //
  542. //
  543. //
  544. //
  545. //
  546. //
  547. //
  548. //
  549. //
  550. //
  551. //
  552. /* harmony default export */ var transfer_panelvue_type_script_lang_js_ = ({
  553. mixins: [locale_default.a],
  554. name: 'ElTransferPanel',
  555. componentName: 'ElTransferPanel',
  556. components: {
  557. ElCheckboxGroup: checkbox_group_default.a,
  558. ElCheckbox: checkbox_default.a,
  559. ElInput: input_default.a,
  560. OptionContent: {
  561. props: {
  562. option: Object
  563. },
  564. render: function render(h) {
  565. var getParent = function getParent(vm) {
  566. if (vm.$options.componentName === 'ElTransferPanel') {
  567. return vm;
  568. } else if (vm.$parent) {
  569. return getParent(vm.$parent);
  570. } else {
  571. return vm;
  572. }
  573. };
  574. var panel = getParent(this);
  575. var transfer = panel.$parent || panel;
  576. return panel.renderContent ? panel.renderContent(h, this.option) : transfer.$scopedSlots.default ? transfer.$scopedSlots.default({ option: this.option }) : h('span', [this.option[panel.labelProp] || this.option[panel.keyProp]]);
  577. }
  578. }
  579. },
  580. props: {
  581. data: {
  582. type: Array,
  583. default: function _default() {
  584. return [];
  585. }
  586. },
  587. renderContent: Function,
  588. placeholder: String,
  589. title: String,
  590. filterable: Boolean,
  591. format: Object,
  592. filterMethod: Function,
  593. defaultChecked: Array,
  594. props: Object
  595. },
  596. data: function data() {
  597. return {
  598. checked: [],
  599. allChecked: false,
  600. query: '',
  601. inputHover: false,
  602. checkChangeByUser: true
  603. };
  604. },
  605. watch: {
  606. checked: function checked(val, oldVal) {
  607. this.updateAllChecked();
  608. if (this.checkChangeByUser) {
  609. var movedKeys = val.concat(oldVal).filter(function (v) {
  610. return val.indexOf(v) === -1 || oldVal.indexOf(v) === -1;
  611. });
  612. this.$emit('checked-change', val, movedKeys);
  613. } else {
  614. this.$emit('checked-change', val);
  615. this.checkChangeByUser = true;
  616. }
  617. },
  618. data: function data() {
  619. var _this = this;
  620. var checked = [];
  621. var filteredDataKeys = this.filteredData.map(function (item) {
  622. return item[_this.keyProp];
  623. });
  624. this.checked.forEach(function (item) {
  625. if (filteredDataKeys.indexOf(item) > -1) {
  626. checked.push(item);
  627. }
  628. });
  629. this.checkChangeByUser = false;
  630. this.checked = checked;
  631. },
  632. checkableData: function checkableData() {
  633. this.updateAllChecked();
  634. },
  635. defaultChecked: {
  636. immediate: true,
  637. handler: function handler(val, oldVal) {
  638. var _this2 = this;
  639. if (oldVal && val.length === oldVal.length && val.every(function (item) {
  640. return oldVal.indexOf(item) > -1;
  641. })) return;
  642. var checked = [];
  643. var checkableDataKeys = this.checkableData.map(function (item) {
  644. return item[_this2.keyProp];
  645. });
  646. val.forEach(function (item) {
  647. if (checkableDataKeys.indexOf(item) > -1) {
  648. checked.push(item);
  649. }
  650. });
  651. this.checkChangeByUser = false;
  652. this.checked = checked;
  653. }
  654. }
  655. },
  656. computed: {
  657. filteredData: function filteredData() {
  658. var _this3 = this;
  659. return this.data.filter(function (item) {
  660. if (typeof _this3.filterMethod === 'function') {
  661. return _this3.filterMethod(_this3.query, item);
  662. } else {
  663. var label = item[_this3.labelProp] || item[_this3.keyProp].toString();
  664. return label.toLowerCase().indexOf(_this3.query.toLowerCase()) > -1;
  665. }
  666. });
  667. },
  668. checkableData: function checkableData() {
  669. var _this4 = this;
  670. return this.filteredData.filter(function (item) {
  671. return !item[_this4.disabledProp];
  672. });
  673. },
  674. checkedSummary: function checkedSummary() {
  675. var checkedLength = this.checked.length;
  676. var dataLength = this.data.length;
  677. var _format = this.format,
  678. noChecked = _format.noChecked,
  679. hasChecked = _format.hasChecked;
  680. if (noChecked && hasChecked) {
  681. return checkedLength > 0 ? hasChecked.replace(/\${checked}/g, checkedLength).replace(/\${total}/g, dataLength) : noChecked.replace(/\${total}/g, dataLength);
  682. } else {
  683. return checkedLength + '/' + dataLength;
  684. }
  685. },
  686. isIndeterminate: function isIndeterminate() {
  687. var checkedLength = this.checked.length;
  688. return checkedLength > 0 && checkedLength < this.checkableData.length;
  689. },
  690. hasNoMatch: function hasNoMatch() {
  691. return this.query.length > 0 && this.filteredData.length === 0;
  692. },
  693. inputIcon: function inputIcon() {
  694. return this.query.length > 0 && this.inputHover ? 'circle-close' : 'search';
  695. },
  696. labelProp: function labelProp() {
  697. return this.props.label || 'label';
  698. },
  699. keyProp: function keyProp() {
  700. return this.props.key || 'key';
  701. },
  702. disabledProp: function disabledProp() {
  703. return this.props.disabled || 'disabled';
  704. },
  705. hasFooter: function hasFooter() {
  706. return !!this.$slots.default;
  707. }
  708. },
  709. methods: {
  710. updateAllChecked: function updateAllChecked() {
  711. var _this5 = this;
  712. var checkableDataKeys = this.checkableData.map(function (item) {
  713. return item[_this5.keyProp];
  714. });
  715. this.allChecked = checkableDataKeys.length > 0 && checkableDataKeys.every(function (item) {
  716. return _this5.checked.indexOf(item) > -1;
  717. });
  718. },
  719. handleAllCheckedChange: function handleAllCheckedChange(value) {
  720. var _this6 = this;
  721. this.checked = value ? this.checkableData.map(function (item) {
  722. return item[_this6.keyProp];
  723. }) : [];
  724. },
  725. clearQuery: function clearQuery() {
  726. if (this.inputIcon === 'circle-close') {
  727. this.query = '';
  728. }
  729. }
  730. }
  731. });
  732. // CONCATENATED MODULE: ./packages/transfer/src/transfer-panel.vue?vue&type=script&lang=js&
  733. /* harmony default export */ var src_transfer_panelvue_type_script_lang_js_ = (transfer_panelvue_type_script_lang_js_);
  734. // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
  735. var componentNormalizer = __webpack_require__(0);
  736. // CONCATENATED MODULE: ./packages/transfer/src/transfer-panel.vue
  737. /* normalize component */
  738. var component = Object(componentNormalizer["a" /* default */])(
  739. src_transfer_panelvue_type_script_lang_js_,
  740. transfer_panelvue_type_template_id_2ddab8bd_render,
  741. transfer_panelvue_type_template_id_2ddab8bd_staticRenderFns,
  742. false,
  743. null,
  744. null,
  745. null
  746. )
  747. /* hot reload */
  748. if (false) { var api; }
  749. component.options.__file = "packages/transfer/src/transfer-panel.vue"
  750. /* harmony default export */ var transfer_panel = (component.exports);
  751. // EXTERNAL MODULE: external "element-ui/lib/mixins/migrating"
  752. var migrating_ = __webpack_require__(11);
  753. var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
  754. // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/transfer/src/main.vue?vue&type=script&lang=js&
  755. //
  756. //
  757. //
  758. //
  759. //
  760. //
  761. //
  762. //
  763. //
  764. //
  765. //
  766. //
  767. //
  768. //
  769. //
  770. //
  771. //
  772. //
  773. //
  774. //
  775. //
  776. //
  777. //
  778. //
  779. //
  780. //
  781. //
  782. //
  783. //
  784. //
  785. //
  786. //
  787. //
  788. //
  789. //
  790. //
  791. //
  792. //
  793. //
  794. //
  795. //
  796. //
  797. //
  798. /* harmony default export */ var mainvue_type_script_lang_js_ = ({
  799. name: 'ElTransfer',
  800. mixins: [emitter_default.a, locale_default.a, migrating_default.a],
  801. components: {
  802. TransferPanel: transfer_panel,
  803. ElButton: button_default.a
  804. },
  805. props: {
  806. data: {
  807. type: Array,
  808. default: function _default() {
  809. return [];
  810. }
  811. },
  812. titles: {
  813. type: Array,
  814. default: function _default() {
  815. return [];
  816. }
  817. },
  818. buttonTexts: {
  819. type: Array,
  820. default: function _default() {
  821. return [];
  822. }
  823. },
  824. filterPlaceholder: {
  825. type: String,
  826. default: ''
  827. },
  828. filterMethod: Function,
  829. leftDefaultChecked: {
  830. type: Array,
  831. default: function _default() {
  832. return [];
  833. }
  834. },
  835. rightDefaultChecked: {
  836. type: Array,
  837. default: function _default() {
  838. return [];
  839. }
  840. },
  841. renderContent: Function,
  842. value: {
  843. type: Array,
  844. default: function _default() {
  845. return [];
  846. }
  847. },
  848. format: {
  849. type: Object,
  850. default: function _default() {
  851. return {};
  852. }
  853. },
  854. filterable: Boolean,
  855. props: {
  856. type: Object,
  857. default: function _default() {
  858. return {
  859. label: 'label',
  860. key: 'key',
  861. disabled: 'disabled'
  862. };
  863. }
  864. },
  865. targetOrder: {
  866. type: String,
  867. default: 'original'
  868. }
  869. },
  870. data: function data() {
  871. return {
  872. leftChecked: [],
  873. rightChecked: []
  874. };
  875. },
  876. computed: {
  877. dataObj: function dataObj() {
  878. var key = this.props.key;
  879. return this.data.reduce(function (o, cur) {
  880. return (o[cur[key]] = cur) && o;
  881. }, {});
  882. },
  883. sourceData: function sourceData() {
  884. var _this = this;
  885. return this.data.filter(function (item) {
  886. return _this.value.indexOf(item[_this.props.key]) === -1;
  887. });
  888. },
  889. targetData: function targetData() {
  890. var _this2 = this;
  891. if (this.targetOrder === 'original') {
  892. return this.data.filter(function (item) {
  893. return _this2.value.indexOf(item[_this2.props.key]) > -1;
  894. });
  895. } else {
  896. return this.value.reduce(function (arr, cur) {
  897. var val = _this2.dataObj[cur];
  898. if (val) {
  899. arr.push(val);
  900. }
  901. return arr;
  902. }, []);
  903. }
  904. },
  905. hasButtonTexts: function hasButtonTexts() {
  906. return this.buttonTexts.length === 2;
  907. }
  908. },
  909. watch: {
  910. value: function value(val) {
  911. this.dispatch('ElFormItem', 'el.form.change', val);
  912. }
  913. },
  914. methods: {
  915. getMigratingConfig: function getMigratingConfig() {
  916. return {
  917. props: {
  918. 'footer-format': 'footer-format is renamed to format.'
  919. }
  920. };
  921. },
  922. onSourceCheckedChange: function onSourceCheckedChange(val, movedKeys) {
  923. this.leftChecked = val;
  924. if (movedKeys === undefined) return;
  925. this.$emit('left-check-change', val, movedKeys);
  926. },
  927. onTargetCheckedChange: function onTargetCheckedChange(val, movedKeys) {
  928. this.rightChecked = val;
  929. if (movedKeys === undefined) return;
  930. this.$emit('right-check-change', val, movedKeys);
  931. },
  932. addToLeft: function addToLeft() {
  933. var currentValue = this.value.slice();
  934. this.rightChecked.forEach(function (item) {
  935. var index = currentValue.indexOf(item);
  936. if (index > -1) {
  937. currentValue.splice(index, 1);
  938. }
  939. });
  940. this.$emit('input', currentValue);
  941. this.$emit('change', currentValue, 'left', this.rightChecked);
  942. },
  943. addToRight: function addToRight() {
  944. var _this3 = this;
  945. var currentValue = this.value.slice();
  946. var itemsToBeMoved = [];
  947. var key = this.props.key;
  948. this.data.forEach(function (item) {
  949. var itemKey = item[key];
  950. if (_this3.leftChecked.indexOf(itemKey) > -1 && _this3.value.indexOf(itemKey) === -1) {
  951. itemsToBeMoved.push(itemKey);
  952. }
  953. });
  954. currentValue = this.targetOrder === 'unshift' ? itemsToBeMoved.concat(currentValue) : currentValue.concat(itemsToBeMoved);
  955. this.$emit('input', currentValue);
  956. this.$emit('change', currentValue, 'right', this.leftChecked);
  957. },
  958. clearQuery: function clearQuery(which) {
  959. if (which === 'left') {
  960. this.$refs.leftPanel.query = '';
  961. } else if (which === 'right') {
  962. this.$refs.rightPanel.query = '';
  963. }
  964. }
  965. }
  966. });
  967. // CONCATENATED MODULE: ./packages/transfer/src/main.vue?vue&type=script&lang=js&
  968. /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
  969. // CONCATENATED MODULE: ./packages/transfer/src/main.vue
  970. /* normalize component */
  971. var main_component = Object(componentNormalizer["a" /* default */])(
  972. src_mainvue_type_script_lang_js_,
  973. render,
  974. staticRenderFns,
  975. false,
  976. null,
  977. null,
  978. null
  979. )
  980. /* hot reload */
  981. if (false) { var main_api; }
  982. main_component.options.__file = "packages/transfer/src/main.vue"
  983. /* harmony default export */ var main = (main_component.exports);
  984. // CONCATENATED MODULE: ./packages/transfer/index.js
  985. /* istanbul ignore next */
  986. main.install = function (Vue) {
  987. Vue.component(main.name, main);
  988. };
  989. /* harmony default export */ var transfer = __webpack_exports__["default"] = (main);
  990. /***/ })
  991. /******/ });