index.vue 13 KB

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