index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. // phonenum: [{
  211. // required: true, message: '请输入联系电话', trigger: 'blur'
  212. // }],
  213. financeType: [{
  214. required: true, message: '请输入财务系统类型', trigger: 'change'
  215. }],
  216. province: [{
  217. required: true, message: '请选择地址', trigger: 'change'
  218. }],
  219. address: [{
  220. required: true, message: '请输入详细地址', trigger: 'blur'
  221. }],
  222. }
  223. },
  224. columns: [
  225. [
  226. {
  227. span: 6,
  228. label: '机构分类',
  229. prop: 'categoryName',
  230. component: 'select-tree',
  231. compConfig: {
  232. attr: {
  233. label: 'name',
  234. clearable: true,
  235. retConfig: {
  236. categoryId: 'id',
  237. categoryName: 'name',
  238. },
  239. defaultExpandAll: true
  240. },
  241. request: {
  242. url: '/maindata/maindataOrganizationCategory/treeUseList'
  243. }
  244. }
  245. },
  246. {
  247. span: 6,
  248. label: '名称',
  249. prop: 'name',
  250. component: 'by-input',
  251. },
  252. {
  253. span: 6,
  254. label: '负责人',
  255. prop: 'contacts',
  256. component: 'by-input',
  257. },
  258. {
  259. span: 6,
  260. label: '手机号码',
  261. prop: 'telephone',
  262. component: 'by-input',
  263. },
  264. {
  265. span: 6,
  266. label: '联系电话',
  267. prop: 'phonenum',
  268. component: 'by-input',
  269. },
  270. ],
  271. [
  272. {
  273. span: 6,
  274. labelWidth: '110px',
  275. label: '财务系统类型',
  276. prop: 'financeType',
  277. component: 'by-select',
  278. compConfig: {
  279. attr: {
  280. placeholder: '请选择财务系统类型',
  281. clearable: true,
  282. size: 'small',
  283. data: [
  284. {
  285. value: 'kingdee',
  286. label: '金蝶K3'
  287. },
  288. // {
  289. // value: 'yonbip',
  290. // label: '用友U8'
  291. // },
  292. ]
  293. }
  294. }
  295. },
  296. ],
  297. [
  298. {
  299. span: 18,
  300. label: 'URL地址',
  301. slot: true,
  302. prop: 'k3ServerUrl',
  303. },
  304. ],
  305. [
  306. {
  307. span: 6,
  308. label: '登录授权ID',
  309. slot: true,
  310. prop: 'k3AppId',
  311. component: 'by-input',
  312. },
  313. {
  314. span: 6,
  315. label: '用户名称',
  316. slot: true,
  317. prop: 'k3UserName',
  318. component: 'by-input',
  319. },
  320. {
  321. span: 6,
  322. label: '数据中心ID',
  323. slot: true,
  324. prop: 'k3AcctId',
  325. component: 'by-input',
  326. },
  327. {
  328. span: 6,
  329. label: '应用秘钥',
  330. slot: true,
  331. prop: 'k3AppSec',
  332. component: 'by-input',
  333. },
  334. ],
  335. [{
  336. span: 18,
  337. label: '地址',
  338. prop: 'province',
  339. component: 'by-area',
  340. labelWidth: '100px',
  341. compConfig: {
  342. attr: {
  343. province: 'province', //省
  344. provinceCode: 'provinceCode', //省编码
  345. city: 'city', //市
  346. cityCode: 'cityCode', //市编码
  347. county: 'region', //县/区
  348. countyCode: 'regionCode', //县/区编码
  349. town: 'street', //街道
  350. townCode: 'streetCode', //街道编码
  351. }
  352. }
  353. }],
  354. [
  355. {
  356. span: 18,
  357. label: '详细地址',
  358. slot: true,
  359. prop: 'address',
  360. component: 'by-input',
  361. },
  362. ],
  363. [
  364. {
  365. span: 6,
  366. label: '状态',
  367. slot: true,
  368. prop: 'status',
  369. },
  370. ]
  371. ]
  372. }
  373. mounted() {
  374. this.timer = setInterval(() => {
  375. this.getDataList()
  376. }, 300)
  377. this.getTreeList();
  378. }
  379. getTreeList(){
  380. api.treeList('maindataOrganizationCategory').then((res : any) => {
  381. console.log(res);
  382. var data:any = [{
  383. id: 0,
  384. name: '机构分类',
  385. children: res.data
  386. }];
  387. (this as any).$refs.sideTree.setData(data);
  388. })
  389. }
  390. //点击树获取数据
  391. onChangeTree(e : any) {
  392. this.categoryIds = e.id;
  393. let loading = this.$loading({ target: '.main-container' });
  394. api.byCategoryPage({ categoryId: e.id, type: 3 }, 'maindataOrganizationCategory').then((res : any) => {
  395. if (res.code === 200) {
  396. (this.$refs.moduleView as any).setTableValue(res.data.records);
  397. let page = {
  398. pageNo: res.data.current, //当前页
  399. pageSize: res.data.size, //每页条数
  400. total: res.data.total //总条数
  401. };
  402. (this.$refs.moduleView as any).setPage(page);
  403. loading.close();
  404. } else loading.close();
  405. }).catch(() => loading.close());
  406. }
  407. // 内页工具栏方法
  408. insideTools(e : any) {
  409. console.log(e);
  410. if (e === 'onReturn') this.isShow = 'home';
  411. if (e === 'onSave') this.confirm();
  412. }
  413. // 保存新增/编辑
  414. confirm() {
  415. (this as any).$refs.addFormId.validate().then(() => {
  416. let query = (this as any).$refs.addFormId.getValue();
  417. query.status = this.radio;
  418. query.accountId = this.$store.getters.userInfo.userId;
  419. // 手机验证
  420. let reg = /^1[3456789]\d{9}$/;
  421. // let reg2 = /^0\d{2,3}-\d{7,8}$/;
  422. if (query.telephone && !reg.test(query.telephone)) return this.$message.warning('请输入正确手机号码');
  423. // if (query.phonenum && !reg2.test(query.phonenum)) return this.$message.warning('请输入正确联系电话');
  424. if(query.phonenum){
  425. if (query.phonenum.length>20 || query.phonenum[0]==' ') {
  426. return this.$message.warning('请输入正确联系电话');
  427. }
  428. }
  429. if (!query.telephone) query.telephone = null;
  430. if (!query.phonenum) query.phonenum = null;
  431. this.dialogFormVisible = false;
  432. console.log(query);
  433. let loading = this.$loading({ target: '.main-container' });
  434. if (this.popTitle === '新增') {
  435. api.saveList(query, 'maindataMaterialManufacturer').then((res : any) => {
  436. loading.close();
  437. if (res.code === 200) {
  438. this.$message.success('保存成功');
  439. // (this as any).$refs.sideTree.request();
  440. this.getTreeList();
  441. this.isShow = 'home'; // 展示类型
  442. this.getDataList();
  443. } else this.$message.error(res.msg);
  444. }).catch(() => loading.close());
  445. } else if (this.popTitle === '编辑') {
  446. api.updateList(query, 'maindataMaterialManufacturer').then((res : any) => {
  447. loading.close();
  448. if (res.code === 200) {
  449. this.$message.success('编辑成功');
  450. // (this as any).$refs.sideTree.request();
  451. this.getTreeList();
  452. this.isShow = 'home'; // 展示类型
  453. this.getDataList();
  454. } else this.$message.error(res.msg);
  455. }).catch(() => loading.close());
  456. }
  457. }).catch(() => {});
  458. }
  459. // 获取列表数据
  460. getDataList() {
  461. if (!this.$refs.moduleView) {
  462. if (this.timeNum > 5) {
  463. clearInterval(this.timer)
  464. }
  465. this.timeNum++;
  466. return
  467. }
  468. clearInterval(this.timer)
  469. let query = (this.$refs.moduleView as any).getQuery();
  470. if (this.categoryIds) query.categoryIds = this.categoryIds;
  471. console.log('表单字段 ==> ', query);
  472. this.getPageList(query)
  473. }
  474. getPageList(query : any) {
  475. let loading = this.$loading({ target: '.main-container' });
  476. api.pageList(query, 'maindataMaterialManufacturer').then((res : any) => {
  477. loading.close();
  478. if (res.code === 200) {
  479. res.data.records.map((v : any) => {
  480. if (v.financeType === 'kingdee') v.financeType2 = '金蝶K3';
  481. if (v.financeType === 'yonbip') v.financeType2 = '用友U8';
  482. });
  483. (this.$refs.moduleView as any).setTableValue(res.data.records);
  484. let page = {
  485. pageNo: res.data.current, //当前页
  486. pageSize: res.data.size, //每页条数
  487. total: res.data.total //总条数
  488. };
  489. (this.$refs.moduleView as any).setPage(page);
  490. } else this.$message.error(res.msg);
  491. }).catch(() => loading.close());
  492. }
  493. // 工具栏方法
  494. clickHandle(e : any) {
  495. if (e === 'onAdd') this.onAdd();
  496. }
  497. // 打开新增
  498. onAdd() {
  499. this.isShow = 'add'; // 展示类型
  500. this.popTitle = '新增'
  501. this.dialogFormVisible = true;
  502. this.radio = 0
  503. this.$nextTick(() => (this as any).$refs.addFormId.setValue());
  504. }
  505. // 打开编辑
  506. openEdit(e : any) {
  507. console.log('打开编辑 ==> ', e);
  508. this.isShow = 'add'; // 展示类型
  509. this.popTitle = '编辑'
  510. let loading = this.$loading({ target: '.main-container' });
  511. api.single({ id: e.id }, 'maindataMaterialManufacturer').then((res : any) => {
  512. if (res.code === 200) {
  513. let data = res.data;
  514. this.radio = data.status;
  515. this.dialogFormVisible = true;
  516. this.$nextTick(() => (this as any).$refs.addFormId.setValue(data));
  517. loading.close();
  518. } else loading.close();
  519. }).catch(() => loading.close());
  520. }
  521. // 操作删除
  522. doDelete(item : any) {
  523. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  524. confirmButtonText: '确定',
  525. cancelButtonText: '取消',
  526. type: 'warning',
  527. center: true
  528. }).then(() => {
  529. let loading = this.$loading({ target: '.main-container' });
  530. api.deleteList({ ids: item.id }, 'maindataMaterialManufacturer').then((res : any) => {
  531. loading.close();
  532. if (res.code === 200) {
  533. // (this as any).$refs.sideTree.request();
  534. this.getTreeList();
  535. this.getDataList();
  536. this.$message.success('删除成功');
  537. } else this.$message.error(res.msg);
  538. }).catch(() => loading.close());
  539. }).catch(() => this.$message.info('已取消删除'));
  540. }
  541. // 刷新/重置
  542. onRefresh() {
  543. (this as any).$refs.moduleView.clearSearch();
  544. // (this as any).$refs.sideTree.request();
  545. this.getTreeList();
  546. this.categoryIds = '';
  547. this.getDataList();
  548. }
  549. }
  550. </script>
  551. <style lang="scss" scoped>
  552. .my-container {
  553. width: 100%;
  554. box-sizing: border-box;
  555. display: flex;
  556. padding: 16px;
  557. height: 100%;
  558. .bill-left {
  559. position: relative;
  560. border-right: solid #EEE 1px;
  561. padding-right: 16px;
  562. flex-shrink: 0;
  563. .bill-tab {
  564. width: 150px;
  565. height: 100%;
  566. transition: all .5s;
  567. overflow: hidden;
  568. }
  569. .tab-title {
  570. font-size: 16px;
  571. padding-bottom: 16px;
  572. width: 200px;
  573. }
  574. }
  575. .bill-main {
  576. width: calc(100% - 16px);
  577. box-sizing: border-box;
  578. margin-left: 16px;
  579. position: relative;
  580. height: 100%;
  581. overflow-y: hidden;
  582. }
  583. .detil {
  584. width: 100%;
  585. .box-shadow {
  586. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  587. padding: 20px;
  588. border-radius: 4px;
  589. border: 1px solid #e6ebf5;
  590. background-color: #fff;
  591. overflow: hidden;
  592. color: #303133;
  593. -webkit-transition: .3s;
  594. transition: .3s;
  595. margin-top: 20px;
  596. }
  597. }
  598. }
  599. </style>