buttonClick.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import { promptBox } from 'nc-lightapp-front';
  2. import { CARD, CARD_BUTTON, STATUS } from '../../constant';
  3. import { cardBack, cardCreate, cardSave, cardUpdate,cardModify, cardDelete, cardCancel,cardLogOut, cardRefresh, cardCopy, cardAttachment, cardBillTrack, cardCommit, cardUnCommit, cardLinkApprove } from './cardOperator';
  4. import { buttonVisibilityControl } from "./buttonVisibilityControl";
  5. /**
  6. * @description: 卡片页头部按钮操作
  7. * @param: isFromSide 是否来自侧拉区域
  8. * @param: id 当前按钮名
  9. */
  10. const formId = 'card_head';
  11. export function buttonClick(props, id, hotkey, isFromSide) {
  12. // 当前单据的全部数据
  13. let pk =
  14. props.form.getFormItemsValue(this.formId, this.primaryId) &&
  15. props.form.getFormItemsValue(this.formId, this.primaryId).value;
  16. debugger;
  17. switch (id) {
  18. //返回
  19. case CARD_BUTTON.back:
  20. cardBack(props);
  21. break;
  22. //头部 新增
  23. case CARD_BUTTON.create:
  24. debugger;
  25. cardCreate(props);
  26. break;
  27. //头部 保存
  28. case CARD_BUTTON.save:
  29. cardSave({ ...props, json: this.state.json }).then(() => {
  30. if (isFromSide) {
  31. props.cardTable.closeModel(CARD.table_code);
  32. }
  33. });
  34. break;
  35. //头部 保存新增
  36. case CARD_BUTTON.saveAdd:
  37. cardSave({ ...props, json: this.state.json }).then(flag => {
  38. if (flag) {
  39. cardCreate(props);
  40. }
  41. });
  42. break;
  43. //头部 保存提交
  44. case CARD_BUTTON.saveCommit:
  45. cardSave({ ...props, json: this.state.json }).then(flag => {
  46. if (flag) {
  47. cardCommit.call(this, { ...props, json: this.state.json });
  48. }
  49. });
  50. break;
  51. //头部 修改
  52. case CARD_BUTTON.update:
  53. cardUpdate(props);
  54. break;
  55. //头部 变更
  56. case CARD_BUTTON.Modify:
  57. props.form.setFormItemsDisabled(formId, {
  58. pk_org: true, //组织不让编辑
  59. bankdeposit: true,//开户银行不让编辑
  60. account: true,//账户不让编辑
  61. });
  62. cardModify(props);
  63. break;
  64. //头部 查看版本
  65. case CARD_BUTTON.queryVersion :
  66. props.setUrlParam({ status: "version", signal: "card" });
  67. this.initVersionTree();
  68. // buttonVisibilityControl.call(this, props);
  69. // this.forceUpdate();
  70. break;
  71. //头部 复制
  72. case CARD_BUTTON.copy:
  73. cardCopy(props);
  74. break;
  75. //头部 删除
  76. case CARD_BUTTON.delete:
  77. promptBox({
  78. color: STATUS.warning,
  79. title: this.state.json['96H10119-000000'],/* 国际化处理: 删除*/
  80. content: this.state.json['96H10119-000001'],/* 国际化处理: 确定删除吗?*/
  81. beSureBtnClick: () => {
  82. cardDelete({ ...props, json: this.state.json });
  83. }
  84. });
  85. break;
  86. //头部 注销
  87. case CARD_BUTTON.logout:
  88. debugger;
  89. promptBox({
  90. color: STATUS.warning,
  91. title: "注销",/* 国际化处理: 注销*/
  92. content: "确定注销吗",/* 国际化处理: 确定注销吗?*/
  93. beSureBtnClick: () => {
  94. cardLogOut({ ...props, json: this.state.json });
  95. }
  96. });
  97. break;
  98. // 头部 取消
  99. case CARD_BUTTON.cancel:
  100. promptBox({
  101. color: STATUS.warning,
  102. title: this.state.json['96H10119-000002'],/* 国际化处理: 取消*/
  103. content: this.state.json['96H10119-000003'],/* 国际化处理: 是否确认要取消?*/
  104. beSureBtnClick: () => {
  105. cardCancel({ ...props, json: this.state.json });
  106. }
  107. });
  108. break;
  109. //头部 刷新
  110. case CARD_BUTTON.refresh:
  111. cardRefresh({ ...props, json: this.state.json });
  112. break;
  113. //附件
  114. case CARD_BUTTON.attachment:
  115. cardAttachment.call(this, props);
  116. break;
  117. //单据追溯
  118. case CARD_BUTTON.billTrack:
  119. cardBillTrack.call(this, props);
  120. break;
  121. //审批详情
  122. case CARD_BUTTON.approvalLink:
  123. cardLinkApprove.call(this, props);
  124. break;
  125. //单据提交
  126. case CARD_BUTTON.commit:
  127. cardCommit.call(this, { ...props, json: this.state.json });
  128. break;
  129. //单据收回
  130. case CARD_BUTTON.unCommit:
  131. cardUnCommit({ ...props, json: this.state.json });
  132. break;
  133. default:
  134. break;
  135. }
  136. }