index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <!-- 交收登记-->
  3. <a-modal class="custom-detail add-custom "
  4. :title="selectedRow.contracttype===1? '采购合同-交收登记': '销售合同-交收登记'"
  5. v-model:visible="visible"
  6. @cancel="cancel"
  7. width="890px">
  8. <template #footer>
  9. <a-button key="submit"
  10. type="primary"
  11. @click="cancel">取消
  12. </a-button>
  13. <a-button key="submit"
  14. type="primary"
  15. :loading="loading"
  16. @click="submit">交收登记
  17. </a-button>
  18. </template>
  19. <fieldset class="formFieldSet">
  20. <legend>合同基本信息</legend>
  21. <a-form class="inlineForm">
  22. <a-row :gutter="24">
  23. <a-col :span="12">
  24. <a-form-item label="合同编号">
  25. <span class="white">{{ formatValue(selectedRow.contractno) }}</span>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :span="12">
  29. <a-form-item label="定价.
  30. 类型">
  31. <span class="white">{{ getPriceTypeName(selectedRow.pricetype) }}</span>
  32. </a-form-item>
  33. </a-col>
  34. </a-row>
  35. <a-row :gutter="24">
  36. <a-col :span="12">
  37. <a-form-item :label="selectedRow.contracttype===1? '采购方': '销售方'">
  38. <span class="white">{{ formatValue(selectedRow.accountname) }}</span>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :span="12">
  42. <a-form-item label="现货品种">
  43. <span class="white">{{ formatValue(selectedRow.deliverygoodsname) }}</span>
  44. </a-form-item>
  45. </a-col>
  46. </a-row>
  47. <a-row :gutter="24">
  48. <a-col :span="12">
  49. <a-form-item label="合同签署量">
  50. <span class="white">{{ formatValue(selectedRow.qty + selectedRow.enumdicname) }}</span>
  51. </a-form-item>
  52. </a-col>
  53. <a-col :span="12">
  54. <a-form-item label="合同暂定价">
  55. <span class="white">{{ formatValue(selectedRow.price) }}</span>
  56. </a-form-item>
  57. </a-col>
  58. </a-row>
  59. <a-row :gutter="24">
  60. <a-col :span="12">
  61. <a-form-item label="点价合约">
  62. <span class="white">{{ formatValue(selectedRow.goodsname) }}</span>
  63. </a-form-item>
  64. </a-col>
  65. </a-row>
  66. </a-form>
  67. </fieldset>
  68. <fieldset class="formFieldSet">
  69. <legend>已登记信息</legend>
  70. <a-form class="inlineForm">
  71. <a-row :gutter="24">
  72. <a-col :span="12">
  73. <a-form-item label="已定价量">
  74. <span class="white">{{ selectedRow.pricedqty + selectedRow.enumdicname }}</span>
  75. </a-form-item>
  76. </a-col>
  77. <a-col :span="12">
  78. <a-form-item label="已点均价">
  79. <span class="white">{{ formatValue(selectedRow.pricedavg) }}</span>
  80. </a-form-item>
  81. </a-col>
  82. </a-row>
  83. </a-form>
  84. </fieldset>
  85. <fieldset class="formFieldSet">
  86. <legend>本次点价信息</legend>
  87. <a-form class="inlineForm"
  88. ref="formRef"
  89. :model="formState"
  90. :rules="formStateRules">
  91. <a-row :gutter="24">
  92. <a-col :span="12">
  93. <a-form-item label="点价价格" name="PricedPrice">
  94. <a-input-number id="dialogInput" style="width: 200px" v-model:value="formState.PricedPrice" :min="0" placeholder="请输入点价价格"/>
  95. </a-form-item>
  96. </a-col>
  97. <a-col :span="12">
  98. <a-form-item label="升贴水">
  99. <span class="white">{{ formatValue(selectedRow.pricemove) }}</span>
  100. </a-form-item>
  101. </a-col>
  102. </a-row>
  103. <a-row :gutter="24">
  104. <a-col :span="12">
  105. <a-form-item label="商品价格">
  106. <span class="white">{{ Number(selectedRow.pricemove) + Number(formState.PricedPrice) }}</span>
  107. </a-form-item>
  108. </a-col>
  109. <a-col :span="12">
  110. <a-form-item label="点价数量" name="PricedQty">
  111. <a-input-number id="dialogInput" style="width: 200px" v-model:value="formState.PricedQty" :min="0" :max="selectedRow.unpricedqty" placeholder="请输入点价数量"/>
  112. <span class="white">未定价量{{selectedRow.unpricedqty}}{{selectedRow.enumdicname}} </span>
  113. <span class="white" @click="formState.PricedQty = selectedRow.unpricedqty"> 全部登记</span>
  114. </a-form-item>
  115. </a-col>
  116. </a-row>
  117. <a-row :gutter="24">
  118. <a-col :span="12">
  119. <a-form-item label="点价金额">
  120. <span class="white">{{( Number(selectedRow.pricemove) + Number(formState.PricedPrice)) * formState.PricedQty }}</span>
  121. </a-form-item>
  122. </a-col>
  123. </a-row>
  124. </a-form>
  125. </fieldset>
  126. </a-modal>
  127. </template>
  128. <script lang="ts">
  129. import {defineComponent, PropType, reactive, ref,unref} from 'vue';
  130. import {closeModal} from '@/common/setup/modal/index';
  131. import {formatValue} from "@/common/methods";
  132. import {Ermcp3SellBuyContract} from "@/services/go/ermcp/purchase/interface";
  133. import {getPriceTypeName} from "@/views/business/purchase/setup";
  134. import { operationContractReq } from '@/services/proto/contract';
  135. import { message } from 'ant-design-vue';
  136. export default defineComponent({
  137. name: 'purchase_pending_settlement',
  138. components: {},
  139. props: {
  140. selectedRow: {
  141. type: Object as PropType<Ermcp3SellBuyContract>,
  142. default: {},
  143. },
  144. },
  145. setup(props) {
  146. const {visible, cancel} = closeModal('purchase_pending_settlement');
  147. const loading = ref<boolean>(false);
  148. function objectToUint8Array(data: object) {
  149. const encode = encodeURI(JSON.stringify(data));// 对字符串进行编码
  150. const base64String = btoa(encode);// 对编码的字符串转化base64
  151. const padding = '='.repeat((4 - base64String.length % 4) % 4);
  152. const base64 = (base64String + padding).replace(/\-/g, '+').replace(/_/g, '/');
  153. const rawData = window.atob(base64);
  154. const outputArray = new Uint8Array(rawData.length);
  155. for (var i = 0; i < rawData.length; ++i) {
  156. outputArray[i] = rawData.charCodeAt(i);
  157. }
  158. return outputArray;
  159. }
  160. const formRef = ref();
  161. const formState = reactive({ PricedPrice: 0, PricedQty: 0 });
  162. const numberIstrue = (rule: any, value: any) => {
  163. if (!value) {
  164. return Promise.reject(new Error('请输入正确的值'));
  165. } else {
  166. return Promise.resolve();
  167. }
  168. };
  169. const formStateRules = {
  170. PricedPrice: [{ required: true, validator: numberIstrue, trigger: 'blur', type: 'number' }],
  171. PricedQty: [{ required: true, validator: numberIstrue, trigger: 'blur', type: 'number' }],
  172. }
  173. function submit() {
  174. const wrapEl = unref(formRef);
  175. wrapEl.validate().then(() => {
  176. loading.value = true;
  177. console.log(objectToUint8Array(formState));
  178. operationContractReq({
  179. OperateType: 1, // uint32 操作类型-1:登记2:确认3:拒绝4:撤销
  180. Info: {
  181. OperateApplyType: 1, // uint32 操作申请类型-1:点价2:结算3:款项4:发票
  182. RelatedID: 1, // uint64 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
  183. DetailJson : objectToUint8Array(formState), // bytes 明细JSON {}
  184. }
  185. }).then(()=>{
  186. message.success('登记成功!')
  187. loading.value = false;
  188. cancel();
  189. }).catch(err=>{
  190. message.error(err)
  191. loading.value = false;
  192. cancel();
  193. })
  194. });
  195. }
  196. return {
  197. visible,
  198. cancel,
  199. submit,
  200. loading,
  201. formRef,
  202. formState,
  203. formatValue,
  204. formStateRules,
  205. getPriceTypeName,
  206. };
  207. },
  208. });
  209. </script>
  210. <style lang="less">
  211. </style>;