index.vue 13 KB

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