containerNumber.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <!-- 中文下拉 -->
  3. <div>
  4. <div style="display: flex;">
  5. <el-input v-model="value" @input="inputChange" :placeholder="'请选择 ' + placeholder" :disabled="true" :size="size" readonly>
  6. <el-button slot="prepend" icon="el-icon-search" @click="open()" :disabled="disabled"></el-button>
  7. </el-input>
  8. </div>
  9. <el-dialog :title="titleDialog" :visible.sync="dialogVisible" width="70%" :before-close="false" @closed="closed" append-to-body>
  10. <span>
  11. <avue-crud
  12. v-if="dialogVisible"
  13. :option="option"
  14. :table-loading="loading"
  15. :data="dataList"
  16. :search.sync="query"
  17. v-model="form"
  18. id="out-table"
  19. ref="crud"
  20. @row-del="rowDel"
  21. @search-change="searchChange"
  22. @search-reset="searchReset"
  23. @on-load="onLoad"
  24. @current-row-change="handleCurrentRowChange"
  25. >
  26. </avue-crud>
  27. </span>
  28. <span slot="footer" class="dialog-footer">
  29. <el-button size="small" @click="dialogVisible = false">取 消</el-button>
  30. <el-button size="small" type="primary" @click="importData">确 定</el-button>
  31. </span>
  32. </el-dialog>
  33. </div>
  34. </template>
  35. <script>
  36. import { getDicinit } from "@/api/dicSelect/index";
  37. import { bcorpstypedefineList } from "@/api/iosBasicData/bcorpstypedefine";
  38. export default {
  39. data() {
  40. return {
  41. quotationObj: null,
  42. dialogVisible: false,
  43. options: [],
  44. loading: false,
  45. data: {},
  46. form: {},
  47. query: {},
  48. page: {
  49. pageSize: 10,
  50. currentPage: 1,
  51. total: 0
  52. },
  53. dataList: [],
  54. selectionList: [],
  55. option: {
  56. height: 400,
  57. calcHeight: 30,
  58. tip: false,
  59. searchIcon: true,
  60. searchIndex: 3,
  61. searchShow: true,
  62. searchMenuSpan: 12,
  63. border: true,
  64. index: true,
  65. // selection: true,
  66. highlightCurrentRow: true,
  67. header: false,
  68. menu: false,
  69. column: [
  70. {
  71. label: "放箱号",
  72. prop: "containerNumber",
  73. width: 100,
  74. overHidden: true,
  75. search: true
  76. },
  77. {
  78. label: "放箱号类型",
  79. prop: "busType",
  80. width: 100,
  81. overHidden: true
  82. },
  83. {
  84. label: "场站",
  85. prop: "polStationId",
  86. width: 100,
  87. overHidden: true,
  88. hide:true,
  89. search: true,
  90. type: "select",
  91. filterable: true,
  92. remote: true,
  93. dicUrl: "/api/blade-los/bcorps/selectList?corpTypeName=场站&status=0&size=10&current=1&cnName={{key}}",
  94. props: {
  95. label: "cnName",
  96. value: "id",
  97. desc: "code",
  98. res: "data.records"
  99. }
  100. },
  101. {
  102. label: "场站",
  103. prop: "polStationCname",
  104. width: 100,
  105. overHidden: true,
  106. },
  107. {
  108. label: "箱型",
  109. prop: "boxType",
  110. width: 100,
  111. overHidden: true
  112. },
  113. {
  114. label: "可用箱数",
  115. prop: "remainingNum",
  116. width: 100,
  117. overHidden: true
  118. },
  119. {
  120. label: "占用箱量",
  121. prop: "occupyNum",
  122. width: 100,
  123. overHidden: true
  124. },
  125. {
  126. label: "优先等级",
  127. prop: "priorityLevel",
  128. type: "select",
  129. dicUrl: "/api/blade-system/dict-biz/dictionary?code=priorityLevel",
  130. props: {
  131. label: "dictValue",
  132. value: "dictKey"
  133. },
  134. width: 100,
  135. overHidden: true
  136. },
  137. {
  138. label: "箱管备注",
  139. prop: "boxRemarks",
  140. width: 100,
  141. overHidden: true
  142. },
  143. {
  144. label: "备注",
  145. prop: "remarks",
  146. width: 100,
  147. overHidden: true
  148. }
  149. ],
  150. designer: null
  151. },
  152. treeOption: {
  153. nodeKey: "id",
  154. lazy: true,
  155. treeLoad: function(node, resolve) {
  156. const parentId = node.level === 0 ? 0 : node.data.id;
  157. },
  158. addBtn: false,
  159. menu: false,
  160. size: "small",
  161. props: {
  162. labelText: "标题",
  163. label: "cnName",
  164. value: "id",
  165. children: "children"
  166. }
  167. },
  168. treeData: [],
  169. selectWidth: 0,
  170. obtained: true
  171. };
  172. },
  173. props: {
  174. activateCreated: {
  175. type: Boolean,
  176. default: true
  177. },
  178. slotRight: {
  179. type: Boolean,
  180. default: false
  181. },
  182. diySlot: {
  183. type: Boolean,
  184. default: false
  185. },
  186. key: {
  187. type: [String, Number],
  188. default: null
  189. },
  190. label: {
  191. type: String,
  192. default: ""
  193. },
  194. rightLabel: {
  195. type: String,
  196. default: ""
  197. },
  198. keyValue: {
  199. type: [String, Number],
  200. default: null
  201. },
  202. res: {
  203. type: String,
  204. default: ""
  205. },
  206. placeholder: {
  207. type: String,
  208. default: "请输入"
  209. },
  210. clearable: {
  211. type: Boolean,
  212. default: true
  213. },
  214. value: {
  215. type: [String, Number],
  216. default: ""
  217. },
  218. method: {
  219. type: String,
  220. default: "GET"
  221. },
  222. url: {
  223. type: String,
  224. default: ""
  225. },
  226. dataName: {
  227. type: String,
  228. default: ""
  229. },
  230. multiple: {
  231. type: Boolean,
  232. default: false
  233. },
  234. filterable: {
  235. type: Boolean,
  236. default: false
  237. },
  238. remote: {
  239. type: Boolean,
  240. default: false
  241. },
  242. size: {
  243. type: String,
  244. default: "small"
  245. },
  246. disabled: {
  247. type: Boolean,
  248. default: false
  249. },
  250. searchShow: {
  251. type: Boolean,
  252. default: false
  253. },
  254. treeShow: {
  255. type: Boolean,
  256. default: false
  257. },
  258. mockData: {
  259. type: Array,
  260. default: function() {
  261. return [];
  262. }
  263. },
  264. collapseTags: {
  265. type: Boolean,
  266. default: false
  267. },
  268. default: {
  269. type: Boolean,
  270. default: false
  271. },
  272. defaultValue: {
  273. type: String,
  274. default: ""
  275. },
  276. disabledLabel: {
  277. type: String,
  278. default: ""
  279. },
  280. dataType: {
  281. type: String,
  282. default: ""
  283. },
  284. titleDialog: {
  285. type: String,
  286. default: "客户"
  287. },
  288. multipleStrings: {
  289. type: Boolean,
  290. default: false
  291. },
  292. type: {
  293. type: String,
  294. default: "select"
  295. },
  296. },
  297. model: {
  298. prop: "value",
  299. event: "selectedValue"
  300. },
  301. created() {},
  302. mounted() {
  303. if (this.activateCreated) {
  304. // this.getDicData()
  305. } else {
  306. this.options = this.mockData;
  307. }
  308. if (this.diySlot) {
  309. this.$nextTick(() => {
  310. this.selectWidth = this.$refs.mySelect.$el.offsetWidth;
  311. this.$refs.mySelect.$el.querySelector(".el-select-dropdown").style.width = `${this.selectWidth}px`;
  312. });
  313. }
  314. },
  315. watch: {
  316. value: {
  317. handler(val, oldVal) {
  318. if (this.dataType == "string") {
  319. if (val) {
  320. if (typeof val == "string") {
  321. this.value = val.split(",");
  322. }
  323. } else {
  324. this.value = [];
  325. }
  326. }
  327. },
  328. deep: true,
  329. immediate: true
  330. }
  331. },
  332. methods: {
  333. handleCurrentRowChange(val) {
  334. this.quotationObj = val;
  335. },
  336. visibleChange(status) {
  337. if (status) {
  338. if (this.options.length == 0) {
  339. this.data = {};
  340. this.getDicData();
  341. }
  342. }
  343. },
  344. inputChange() {
  345. if (this.dataType == "string") {
  346. if (this.value && this.value.length) {
  347. this.$emit("selectedValue", this.value.join(","));
  348. } else {
  349. this.$emit("selectedValue", []);
  350. }
  351. } else {
  352. this.$emit("selectedValue", this.value);
  353. }
  354. },
  355. open() {
  356. // this.selectionList = [];
  357. this.dialogVisible = true;
  358. this.quotationObj = null;
  359. this.getTree();
  360. },
  361. // 获取客户类别
  362. getTree() {
  363. bcorpstypedefineList(1, 50).then(res => {
  364. this.treeData = res.data.data.records;
  365. });
  366. },
  367. nodeClick(data) {
  368. this.query.corpTypeName = data.cnName;
  369. this.onLoad(this.page, this.query);
  370. },
  371. closed() {
  372. this.query = {};
  373. this.selectionList = [];
  374. },
  375. remoteMethod(query) {
  376. if (query !== "") {
  377. setTimeout(() => {
  378. this.data[this.dataName] = query;
  379. this.getDicData();
  380. }, 200);
  381. } else {
  382. setTimeout(() => {
  383. this.data = this.$options.data().data;
  384. this.getDicData();
  385. }, 200);
  386. }
  387. },
  388. getDicData() {
  389. if (this.url) {
  390. this.loading = true;
  391. getDicinit(this.method, this.url, this.data)
  392. .then(res => {
  393. if (this.res) {
  394. res.data.data[this.res].forEach(e => {
  395. if (this.disabledLabel.split(",").some(item => item == e[this.label])) {
  396. e.disabled = true;
  397. }
  398. });
  399. this.options = res.data.data[this.res];
  400. } else {
  401. res.data.data.forEach(e => {
  402. if (this.disabledLabel.split(",").some(item => item == e[this.label])) {
  403. e.disabled = true;
  404. }
  405. });
  406. this.options = res.data.data;
  407. }
  408. })
  409. .finally(() => {
  410. this.loading = false;
  411. });
  412. } else {
  413. this.options = this.mockData;
  414. }
  415. },
  416. IdGetDicData(data) {
  417. this.loading = true;
  418. getDicinit(this.method, this.url, data)
  419. .then(res => {
  420. if (this.res) {
  421. this.options = res.data.data[this.res];
  422. } else {
  423. this.options = res.data.data;
  424. }
  425. })
  426. .finally(() => {
  427. this.loading = false;
  428. });
  429. },
  430. selectChange(row) {
  431. if (this.dataType == "string") {
  432. let data = [];
  433. let ids = [];
  434. let multipleData = [];
  435. this.options.forEach(e => {
  436. if (row.length) {
  437. if (this.keyValue) {
  438. row.forEach(item => {
  439. if (item == e[this.keyValue]) {
  440. data.push(e[this.label]);
  441. this.$emit("selectChange", data.join(","));
  442. }
  443. });
  444. }
  445. if (this.label) {
  446. row.forEach(item => {
  447. if (item == e[this.label]) {
  448. ids.push(e.id);
  449. data.push(e[this.label]);
  450. if (this.multipleStrings) {
  451. multipleData.push(e);
  452. this.$emit("selectChange", {
  453. ids: ids.join(","),
  454. names: data.join(","),
  455. multipleData: multipleData
  456. });
  457. } else {
  458. this.$emit("selectChange", {
  459. ids: ids.join(","),
  460. names: data.join(",")
  461. });
  462. }
  463. }
  464. });
  465. }
  466. } else {
  467. this.$emit("selectChange", null);
  468. }
  469. });
  470. } else {
  471. this.options.forEach(e => {
  472. if (this.keyValue) {
  473. if (row == e[this.keyValue]) {
  474. this.$emit("selectChange", e);
  475. }
  476. }
  477. if (this.label) {
  478. if (row == e[this.label]) {
  479. this.$emit("selectChange", e);
  480. }
  481. }
  482. });
  483. }
  484. },
  485. clear() {
  486. if (this.url) {
  487. this.data = this.$options.data().data;
  488. this.getDicData();
  489. }
  490. this.$emit("selectChange", null);
  491. },
  492. importData() {
  493. if (!this.quotationObj) {
  494. return this.$message.error("请选择数据");
  495. }
  496. this.dialogVisible = false;
  497. this.$emit("selectChange", this.quotationObj);
  498. },
  499. searchChange(params, done) {
  500. this.page.currentPage = 1;
  501. this.onLoad(this.page, this.query);
  502. done();
  503. },
  504. selectionChange(list) {
  505. this.selectionList = list;
  506. },
  507. currentChange(currentPage) {
  508. this.page.currentPage = currentPage;
  509. },
  510. sizeChange(pageSize) {
  511. this.page.pageSize = pageSize;
  512. },
  513. refreshChange() {
  514. this.onLoad(this.page, this.query);
  515. },
  516. onLoad(page, params = {}) {
  517. let obj = {};
  518. obj = {
  519. ...Object.assign(params, this.query)
  520. };
  521. this.loading = true;
  522. getDicinit(this.method, this.url, obj)
  523. .then(res => {
  524. this.dataList = res.data.data.filter(item=>item.remainingNum>0);
  525. })
  526. .finally(() => {
  527. this.loading = false;
  528. });
  529. }
  530. }
  531. };
  532. </script>
  533. <style lang="scss" scoped>
  534. /deep/ .el-col-md-8 {
  535. width: 24.33333%;
  536. }
  537. </style>