index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div class="my-container">
  3. <div class="bill-left">
  4. <div class="bill-tab">
  5. <div class="tab-title">导航</div>
  6. <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
  7. </div>
  8. </div>
  9. <div class="bill-main">
  10. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  11. @resert="getDataList" @clickHandle="clickHandle" @detail="openEdit" @onRefresh="onRefresh">
  12. </module-view>
  13. </div>
  14. <!-- 新增/编辑弹窗 -->
  15. <el-dialog :title="popTitle+'供应商'" :visible.sync="dialogFormVisible" width="30%">
  16. <by-form :propConfig="addConfig" ref="addFormId">
  17. <template v-slot:status class="clearfix">
  18. <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">正常</el-radio>
  19. <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="2">禁用</el-radio>
  20. </template>
  21. </by-form>
  22. <div slot="footer" class="dialog-footer">
  23. <el-button @click="dialogFormVisible = false">取 消</el-button>
  24. <el-button type="primary" @click="confirm">确 定</el-button>
  25. </div>
  26. </el-dialog>
  27. </div>
  28. </template>
  29. <script lang="ts">
  30. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  31. import api from "@/api/currency";
  32. import Assembly from "@/components/Assembly/material.vue";
  33. @Component
  34. export default class Supplier extends Vue {
  35. baseURL : any = process.env.VUE_APP_BASE_API
  36. loading : any = null
  37. timeNum = 0;
  38. timer : any = null
  39. popTitle : any = ''
  40. radio : any = 1
  41. dialogFormVisible : boolean = false
  42. parentId: any = '';
  43. treeConfig = {
  44. attr: {
  45. retConfig: {
  46. id: 'id',
  47. name: 'name'
  48. },
  49. defaultExpandAll: true,
  50. label: 'name',
  51. resType: 'data'
  52. },
  53. request: {
  54. url: '/maindata/maindataOrganizationCategory/treeList',
  55. method: 'GET'
  56. }
  57. }
  58. config : any = {
  59. search: {
  60. attr: {
  61. size: 'mini'
  62. },
  63. columns: [
  64. [{
  65. span: 6,
  66. label: '名称',
  67. prop: 'name',
  68. component: 'by-input',
  69. labelWidth: '70px',
  70. compConfig: {
  71. attr: {
  72. placeholder: '请输入名称',
  73. clearable: true
  74. },
  75. },
  76. }, {
  77. span: 6,
  78. label: '负责人',
  79. prop: 'contacts',
  80. component: 'by-input',
  81. labelWidth: '70px',
  82. compConfig: {
  83. attr: {
  84. placeholder: '请输入负责人',
  85. clearable: true
  86. }
  87. }
  88. },
  89. {
  90. span: 6,
  91. label: '状态',
  92. prop: 'status',
  93. labelWidth: '70px',
  94. component: 'by-select',
  95. compConfig: {
  96. attr: {
  97. placeholder: '请选择状态',
  98. clearable: true,
  99. data: [{
  100. value: 1,
  101. label: '正常'
  102. }, {
  103. value: 2,
  104. label: '禁用'
  105. }]
  106. }
  107. }
  108. },
  109. ]
  110. ]
  111. },
  112. tool: {
  113. tools: {
  114. add: true,
  115. delete: true,
  116. search: true,
  117. refresh: true
  118. }
  119. },
  120. table: {
  121. attr: {
  122. size: 'mini',
  123. seq: true,
  124. align: 'center',
  125. checkbox: true,
  126. height: 600
  127. },
  128. columns: [{
  129. title: '名称',
  130. field: 'name',
  131. isDetail: true,
  132. width: 300,
  133. },
  134. {
  135. title: '负责人',
  136. field: 'contacts',
  137. width: 300,
  138. },
  139. {
  140. width: 80,
  141. title: '状态',
  142. field: 'status',
  143. component: Assembly,
  144. }, {
  145. width: 500,
  146. title: '备注',
  147. field: 'remark',
  148. }, {
  149. width: 120,
  150. title: '操作',
  151. action: true,
  152. plugins: [{
  153. icon: 'el-icon-edit',
  154. name: '编辑',
  155. audit: '',
  156. event: {
  157. click: (item : any) => {
  158. (this as any).openEdit(item)
  159. }
  160. }
  161. }, {
  162. name: '删除',
  163. event: {
  164. click: (item : any) => (this as any).doDelete2(item)
  165. }
  166. }]
  167. }]
  168. },
  169. }
  170. addConfig = {
  171. attr: {
  172. size: 'small',
  173. rules: {
  174. name: [{
  175. required: true, message: '请输入名称', trigger: 'blur'
  176. }],
  177. contacts: [{
  178. required: true, message: '请输入负责人', trigger: 'blur'
  179. }]
  180. }
  181. },
  182. columns: [
  183. [
  184. {
  185. span: 23,
  186. labelWidth: '70px',
  187. label: '名称',
  188. prop: 'name',
  189. component: 'by-input',
  190. },
  191. {
  192. span: 23,
  193. labelWidth: '70px',
  194. label: '负责人',
  195. prop: 'contacts',
  196. component: 'by-input',
  197. },
  198. {
  199. span: 23,
  200. labelWidth: '70px',
  201. label: '状态',
  202. slot: true,
  203. prop: 'status',
  204. },
  205. ],
  206. [
  207. {
  208. span: 23,
  209. labelWidth: '70px',
  210. label: '备注',
  211. prop: 'remark',
  212. component: 'by-input',
  213. compConfig: {
  214. attr: {
  215. size: 'mini',
  216. placeholder: '请输入备注',
  217. type: 'textarea'
  218. },
  219. }
  220. },
  221. ]
  222. ]
  223. }
  224. mounted() {
  225. this.timer = setInterval(() => {
  226. this.getDataList()
  227. }, 300)
  228. }
  229. //点击树获取数据
  230. onChangeTree(e : any) {
  231. console.log('点击结果:', e)
  232. this.parentId = e.id[0]
  233. api.childrenTreeList({ id: e.id[0], pageNo: 1, pageSize: 999 }, 'maindataMaterialManufacturer').then((res : any) => {
  234. if (res.code === 200) {
  235. (this.$refs.moduleView as any).setTableValue(res.data);
  236. let page = {
  237. pageNo: res.data.current, //当前页
  238. pageSize: res.data.size, //每页条数
  239. total: res.data.total //总条数
  240. };
  241. (this.$refs.moduleView as any).setPage(page)
  242. }
  243. })
  244. }
  245. // 确认新增/编辑
  246. confirm() {
  247. (this as any).$refs.addFormId.validate().then(() => {
  248. let query = (this as any).$refs.addFormId.getValue();
  249. console.log(query);
  250. query.status = this.radio;
  251. this.dialogFormVisible = false;
  252. if (this.popTitle === '新增') {
  253. api.saveList(query, 'maindataMaterialManufacturer').then((res : any) => {
  254. if (res.code === 200) {
  255. this.$message.success(this.popTitle + '成功!');
  256. (this as any).$refs.sideTree.request();
  257. this.getDataList();
  258. } else this.$message.error(res.msg);
  259. })
  260. } else if (this.popTitle === '编辑') {
  261. api.updateList(query, 'maindataMaterialManufacturer').then((res : any) => {
  262. if (res.code === 200) {
  263. this.$message.success(this.popTitle + '成功!');
  264. (this as any).$refs.sideTree.request();
  265. this.getDataList();
  266. } else this.$message.error(res.msg);
  267. })
  268. }
  269. })
  270. }
  271. // 获取列表数据
  272. getDataList() {
  273. if (!this.$refs.moduleView) {
  274. if (this.timeNum > 5) {
  275. clearInterval(this.timer)
  276. }
  277. this.timeNum++;
  278. return
  279. }
  280. clearInterval(this.timer)
  281. let query = (this.$refs.moduleView as any).getQuery();
  282. api.pageList(query, 'maindataMaterialManufacturer').then((res : any) => {
  283. if (res.code === 200) {
  284. (this.$refs.moduleView as any).setTableValue(res.data.records);
  285. let page = {
  286. pageNo: res.data.current, //当前页
  287. pageSize: res.data.size, //每页条数
  288. total: res.data.total //总条数
  289. };
  290. (this.$refs.moduleView as any).setPage(page)
  291. } else this.$message.error(res.msg);
  292. })
  293. }
  294. // 工具栏方法
  295. clickHandle(e : any) {
  296. if (e === 'onAdd') this.onAdd();
  297. if (e === 'onDelete') this.onDelete();
  298. if (e === 'onExport') this.onExport();
  299. }
  300. // 打开新增
  301. onAdd() {
  302. this.popTitle = '新增'
  303. this.dialogFormVisible = true;
  304. this.radio = 1
  305. setTimeout(() => {
  306. if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue('');
  307. }, 0)
  308. }
  309. // 打开编辑
  310. openEdit(e : any) {
  311. this.popTitle = '编辑'
  312. this.dialogFormVisible = true;
  313. this.radio = e.status
  314. setTimeout(() => {
  315. if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue(e);
  316. }, 0)
  317. }
  318. // 工具栏删除
  319. onDelete() {
  320. let selectData = (this.$refs.moduleView as any).getSelectData()
  321. let ids = '';
  322. if (selectData.length > 0) {
  323. selectData.map((v : any) => {
  324. ids += v.id + ','
  325. })
  326. } else return this.$message.warning('请选择删除数据');
  327. ids = ids.slice(0, ids.length - 1);
  328. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  329. confirmButtonText: '确定',
  330. cancelButtonText: '取消',
  331. type: 'warning',
  332. center: true
  333. }).then(() => {
  334. api.deleteList({ ids: ids }, 'maindataMaterialManufacturer').then((res : any) => {
  335. if (res.code === 200) {
  336. (this as any).$refs.sideTree.request();
  337. this.getDataList();
  338. this.$message.success('删除成功!');
  339. } else this.$message.error(res.msg);
  340. })
  341. }).catch(() => this.$message.info('已取消删除'));
  342. }
  343. // 操作删除
  344. doDelete2(item : any) {
  345. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  346. confirmButtonText: '确定',
  347. cancelButtonText: '取消',
  348. type: 'warning',
  349. center: true
  350. }).then(() => {
  351. api.deleteList({ ids: item.id }, 'maindataMaterialManufacturer').then((res : any) => {
  352. if (res.code === 200) {
  353. (this as any).$refs.sideTree.request();
  354. this.getDataList();
  355. this.$message.success('删除成功!');
  356. } else this.$message.error(res.msg);
  357. })
  358. }).catch(() => {
  359. this.$message.info('已取消删除');
  360. });
  361. }
  362. // 刷新
  363. onRefresh() {
  364. this.loading = this.$loading({ target: '.main-container' });
  365. (this as any).$refs.moduleView.clearSearch();
  366. api.pageList({}, 'maindataMaterialManufacturer').then((res : any) => {
  367. if (res.code === 200) {
  368. (this.$refs.moduleView as any).setTableValue(res.data.records);
  369. let page = {
  370. pageNo: res.data.current, //当前页
  371. pageSize: res.data.size, //每页条数
  372. total: res.data.total //总条数
  373. };
  374. (this.$refs.moduleView as any).setPage(page);
  375. this.loading.close();
  376. } else this.$message.error(res.msg);
  377. })
  378. }
  379. //导出
  380. onExport() {
  381. let urlArr = '/maindata/maindataMaterial';
  382. let query = (this.$refs.moduleView as any).getQuery();
  383. (this as any).$download(urlArr + '/export', {
  384. ...query
  385. }, urlArr[urlArr.length - 1] + `_${new Date().getTime()}.xlsx`)
  386. }
  387. }
  388. </script>
  389. <style lang="scss" scoped>
  390. .my-container {
  391. width: 100%;
  392. box-sizing: border-box;
  393. display: flex;
  394. padding: 16px;
  395. .search-btn {
  396. width: 100%;
  397. display: flex;
  398. justify-content: flex-end;
  399. margin-bottom: 20px;
  400. }
  401. .bill-left {
  402. position: relative;
  403. border-right: solid #EEE 1px;
  404. padding-right: 16px;
  405. flex-shrink: 0;
  406. // box-sizing: border-box;
  407. .bill-tab {
  408. width: 150px;
  409. height: 100%;
  410. transition: all .5s;
  411. overflow: hidden;
  412. }
  413. .title {
  414. font-size: 16px;
  415. padding-bottom: 16px;
  416. width: 200px;
  417. }
  418. .bill-nav {
  419. font-size: 14px;
  420. height: 30px;
  421. line-height: 30px;
  422. width: 200px;
  423. box-sizing: border-box;
  424. padding: 0 8px;
  425. cursor: pointer;
  426. margin-bottom: 2px;
  427. border-radius: 5px;
  428. }
  429. .onBill {
  430. background-color: #bde3f7;
  431. }
  432. .bill-nav:hover {
  433. background-color: #bde3f7;
  434. }
  435. .close {
  436. height: 22px;
  437. width: 22px;
  438. border-radius: 50%;
  439. border: solid #EEE 1px;
  440. position: absolute;
  441. top: 30px;
  442. right: -11px;
  443. background-color: #FFF;
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. cursor: pointer;
  448. }
  449. }
  450. .bill-main {
  451. width: calc(100% - 16px);
  452. box-sizing: border-box;
  453. margin-left: 16px;
  454. position: relative;
  455. .bill-box {
  456. width: 100%;
  457. position: absolute;
  458. left: 0;
  459. top: 0;
  460. opacity: 0;
  461. z-index: -1;
  462. transition: all .5s;
  463. .bill-tool,
  464. .table-tool {
  465. width: 100%;
  466. padding-bottom: 16px;
  467. }
  468. .form {
  469. margin-bottom: 8px;
  470. }
  471. }
  472. .on-show {
  473. opacity: 1;
  474. z-index: 1;
  475. }
  476. }
  477. }
  478. </style>