index.vue 15 KB

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