main.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div>
  3. <div style="display:flex">
  4. <el-select
  5. v-if="gysType == 'CK'"
  6. size="small"
  7. v-model="value"
  8. placeholder="请选择"
  9. @input="$emit('balabala', value)"
  10. :disabled="disabled"
  11. filterable
  12. clearable
  13. style="width:100%"
  14. :multiple="multiple ? multiple : false"
  15. :collapse-tags="collapseTags ? collapseTags : false"
  16. @change="corpChange"
  17. >
  18. <el-option
  19. v-for="item in corpList"
  20. :key="item.id"
  21. :label="item.code"
  22. :value="item.id"
  23. >
  24. </el-option>
  25. </el-select>
  26. <el-select
  27. v-else
  28. size="small"
  29. v-model="value"
  30. placeholder="请选择"
  31. @input="$emit('balabala', value)"
  32. :disabled="disabled"
  33. filterable
  34. clearable
  35. style="width:100%"
  36. :multiple="multiple ? multiple : false"
  37. :collapse-tags="collapseTags ? collapseTags : false"
  38. @change="corpChange"
  39. >
  40. <el-option
  41. v-for="item in corpList"
  42. :key="item.id"
  43. :label="item.cname"
  44. :value="item.id"
  45. >
  46. </el-option>
  47. </el-select>
  48. <el-button
  49. icon="el-icon-search"
  50. size="mini"
  51. :disabled="disabled"
  52. @click="openDialog()"
  53. ></el-button>
  54. </div>
  55. <el-dialog
  56. :title="title"
  57. :visible.sync="corpVisible"
  58. width="80%"
  59. top="5vh"
  60. append-to-body
  61. @closed="closed"
  62. class="el-dialogDeep"
  63. :close-on-click-modal="false"
  64. v-dialog-drag
  65. >
  66. <span>
  67. <el-row>
  68. <el-col :span="4">
  69. <el-scrollbar>
  70. <basic-container>
  71. <avue-tree
  72. :option="treeOption"
  73. :data="treeData"
  74. @node-click="nodeClick"
  75. :style="treeStyle"
  76. />
  77. </basic-container>
  78. </el-scrollbar>
  79. </el-col>
  80. <el-col :span="20">
  81. <avue-crud
  82. :option="tableOption"
  83. :data="data"
  84. ref="crud"
  85. v-model="form"
  86. :page.sync="page"
  87. :search.sync="search"
  88. @search-change="searchChange"
  89. @search-reset="searchReset"
  90. @selection-change="selectionChange"
  91. @on-load="onLoad"
  92. @tree-load="treeLoad"
  93. @saveColumn="saveColumn"
  94. @resetColumn="resetColumn"
  95. @refresh-change="refreshChange"
  96. :table-loading="loading"
  97. >
  98. </avue-crud>
  99. </el-col>
  100. </el-row>
  101. </span>
  102. <span slot="footer" class="dialog-footer">
  103. <el-button @click="corpVisible = false">取 消</el-button>
  104. <el-button
  105. type="primary"
  106. @click="importCorp"
  107. :disabled="selectionList.length != 1"
  108. >确 定</el-button
  109. >
  110. </span>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import option from "./configuration/mainList.json";
  116. import option2 from "./configuration/mainList2.json";
  117. import {
  118. customerList,
  119. allCropList,
  120. getDeptLazyTree
  121. } from "@/api/basicData/customerInformation";
  122. import { getCustomerCode, getCustomerName } from "@/enums/management-type";
  123. export default {
  124. data() {
  125. return {
  126. corpList: [],
  127. loading: false,
  128. data: [],
  129. tableOption: {},
  130. form: {},
  131. search: {},
  132. treeDeptId: "",
  133. treeDeptName: "",
  134. page: {
  135. currentPage: 1,
  136. pageSize: 10,
  137. total: 0
  138. },
  139. treeOption: {
  140. nodeKey: "id",
  141. lazy: true,
  142. addBtn: false,
  143. menu: false,
  144. size: "small",
  145. props: {
  146. labelText: "标题",
  147. label: "title",
  148. value: "value",
  149. children: "children"
  150. }
  151. },
  152. corpVisible: false,
  153. selectionList: [],
  154. title: null,
  155. treeStyle: "height:" + (window.innerHeight - 315) + "px"
  156. };
  157. },
  158. props: {
  159. value: String,
  160. disabled: Boolean,
  161. cropIndex: Number,
  162. corpType: String,
  163. multiple: Boolean,
  164. collapseTags: Boolean,
  165. gysType: String,
  166. treeType: String
  167. },
  168. model: {
  169. prop: "value",
  170. event: "balabala"
  171. },
  172. async created() {
  173. if (this.gysType == "CK" && this.corpType == "GYS") {
  174. this.tableOption = await this.getColumnData(
  175. this.getColumnName(99),
  176. option2
  177. );
  178. } else {
  179. this.tableOption = await this.getColumnData(
  180. this.getColumnName(51),
  181. option
  182. );
  183. }
  184. let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  185. this.title = getCustomerName(this.corpType);
  186. allCropList({
  187. corpType: getCustomerCode(this.corpType),
  188. adminProfiles: userObj.role_name != "admin" ? userObj.user_id : null,
  189. corpsTypeName: this.treeType == "CK" ? "货代和物流" : null
  190. }).then(res => {
  191. this.corpList = res.data.data;
  192. });
  193. },
  194. mounted() {},
  195. methods: {
  196. init() {
  197. this.openDialog();
  198. },
  199. openDialog() {
  200. let _this = this;
  201. this.treeOption.treeLoad = function(node, resolve) {
  202. const parentId = node.level === 0 ? 0 : node.data.id;
  203. getDeptLazyTree({
  204. parentId: parentId,
  205. corpType: getCustomerCode(_this.corpType),
  206. cname: _this.treeType == "CK" ? "货代和物流" : null
  207. }).then(res => {
  208. resolve(
  209. res.data.data.map(item => {
  210. return {
  211. ...item,
  212. leaf: !item.hasChildren
  213. };
  214. })
  215. );
  216. });
  217. };
  218. this.corpVisible = true;
  219. },
  220. closed() {
  221. this.$refs.crud.toggleSelection();
  222. },
  223. importCorp() {
  224. this.$emit("balabala", this.selectionList[0].id);
  225. this.$emit("getCorpData", {
  226. ...this.selectionList[0],
  227. index: this.cropIndex
  228. });
  229. this.corpVisible = false;
  230. },
  231. corpChange(row) {
  232. this.corpList.forEach(e => {
  233. if (row == e.id) {
  234. this.$emit("getCorpData", { ...e, index: this.cropIndex });
  235. }
  236. });
  237. },
  238. refreshChange() {
  239. this.onLoad(this.page, this.search);
  240. },
  241. onLoad(page, params = { parentId: 0 }) {
  242. let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  243. let queryParams = Object.assign({}, params, {
  244. size: page.pageSize,
  245. current: page.currentPage,
  246. corpsTypeId: this.treeDeptId,
  247. corpType: getCustomerCode(this.corpType),
  248. adminProfiles: userObj.role_name != "admin" ? userObj.user_id : null,
  249. corpsTypeName: this.treeType == "CK" ? "货代和物流" : null
  250. });
  251. this.loading = true;
  252. customerList(queryParams)
  253. .then(res => {
  254. this.data = res.data.data.records;
  255. this.page.total = res.data.data.total;
  256. if (this.page.total) {
  257. this.tableOption.height = window.innerHeight - 350;
  258. }
  259. })
  260. .finally(() => {
  261. this.loading = false;
  262. });
  263. },
  264. selectionChange(list) {
  265. this.selectionList = list;
  266. },
  267. sizeChange(val) {
  268. this.page.pageSize = val;
  269. this.onLoad();
  270. },
  271. currentChange(val) {
  272. this.page.currentPage = val;
  273. this.onLoad();
  274. },
  275. //列表内展开树节点
  276. treeLoad(tree, treeNode, resolve) {
  277. const parentId = tree.id;
  278. customerList({ parentId: parentId }).then(res => {
  279. resolve(res.data.data.records);
  280. });
  281. },
  282. //点击搜索按钮触发
  283. searchChange(params, done) {
  284. this.page.currentPage = 1;
  285. this.onLoad(this.page, params);
  286. done();
  287. },
  288. searchReset() {
  289. this.treeDeptId = null;
  290. },
  291. nodeClick(data) {
  292. this.treeDeptId = data.id;
  293. this.page.currentPage = 1;
  294. this.onLoad(this.page);
  295. },
  296. //列保存触发
  297. async saveColumn() {
  298. const inSave = await this.saveColumnData(
  299. this.getColumnName(51),
  300. this.option
  301. );
  302. if (inSave) {
  303. this.$message.success("保存成功");
  304. //关闭窗口
  305. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  306. }
  307. },
  308. async resetColumn() {
  309. this.option =
  310. this.gysType == "CK" && this.corpType == "GYS" ? option2 : option;
  311. const inSave = await this.delColumnData(
  312. this.getColumnName(51),
  313. this.gysType == "CK" && this.corpType == "GYS" ? option2 : option
  314. );
  315. if (inSave) {
  316. this.$message.success("重置成功");
  317. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  318. }
  319. }
  320. }
  321. };
  322. </script>
  323. <style scoped lang="scss"></style>