index.vue 16 KB

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