index.vue 16 KB

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