index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <!-- 点价登记-->
  3. <a-modal class="commonModal someprice"
  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. class="cancelBtn"
  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="点价价格"
  94. name="PricedPrice">
  95. <a-input-number class="dialogInput"
  96. style="width: 200px"
  97. v-model:value="formState.PricedPrice"
  98. :min="0"
  99. placeholder="请输入点价价格" />
  100. </a-form-item>
  101. </a-col>
  102. <a-col :span="12">
  103. <a-form-item label="升贴水">
  104. <span class="white">{{ formatValue(selectedRow.pricemove) }}</span>
  105. </a-form-item>
  106. </a-col>
  107. </a-row>
  108. <a-row :gutter="24">
  109. <a-col :span="12">
  110. <a-form-item label="商品价格">
  111. <span class="white">{{ Number(selectedRow.pricemove) + Number(formState.PricedPrice) }}</span>
  112. </a-form-item>
  113. </a-col>
  114. <a-col :span="12">
  115. <a-form-item label="点价数量"
  116. class="relative"
  117. name="PricedQty">
  118. <a-input-number class="dialogInput"
  119. style="width: 200px"
  120. v-model:value="formState.PricedQty"
  121. :min="0"
  122. :max="selectedRow.unpricedqty"
  123. placeholder="请输入点价数量" />
  124. <div class="itemTip">
  125. <span>未定价量<span class="white">{{selectedRow.unpricedqty}}{{selectedRow.enumdicname}}</span> </span>
  126. <span @click="formState.PricedQty = selectedRow.unpricedqty"> 全部登记</span>
  127. </div>
  128. </a-form-item>
  129. </a-col>
  130. </a-row>
  131. <a-row :gutter="24">
  132. <a-col :span="12">
  133. <a-form-item label="点价金额">
  134. <span class="white">{{( Number(selectedRow.pricemove) + Number(formState.PricedPrice)) * formState.PricedQty }}</span>
  135. </a-form-item>
  136. </a-col>
  137. </a-row>
  138. </a-form>
  139. </fieldset>
  140. </a-modal>
  141. </template>
  142. <script lang="ts">
  143. import { defineComponent, PropType, reactive, ref, unref } from 'vue';
  144. import { closeModal } from '@/common/setup/modal/index';
  145. import { formatValue } from '@/common/methods';
  146. import { Ermcp3SellBuyContract } from '@/services/go/ermcp/purchase/interface';
  147. import { getPriceTypeName } from '@/views/business/purchase/setup';
  148. import { operationContractReq } from '@/services/proto/contract';
  149. import { message } from 'ant-design-vue';
  150. import Long from 'long';
  151. export default defineComponent({
  152. name: 'purchase_pending_someprice',
  153. components: {},
  154. props: {
  155. selectedRow: {
  156. type: Object as PropType<Ermcp3SellBuyContract>,
  157. default: {},
  158. },
  159. },
  160. setup(props) {
  161. const { visible, cancel } = closeModal('purchase_pending_someprice');
  162. const loading = ref<boolean>(false);
  163. function objectToUint8Array(data: object) {
  164. const encode = encodeURI(JSON.stringify(data)); // 对字符串进行编码
  165. const base64String = btoa(encode); // 对编码的字符串转化base64
  166. const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
  167. const base64 = (base64String + padding).replace(/\-/g, '+').replace(/_/g, '/');
  168. const rawData = window.atob(base64);
  169. const outputArray = new Uint8Array(rawData.length);
  170. for (var i = 0; i < rawData.length; ++i) {
  171. outputArray[i] = rawData.charCodeAt(i);
  172. }
  173. return outputArray;
  174. }
  175. const formRef = ref();
  176. const formState = reactive({ PricedPrice: 0, PricedQty: 0 });
  177. const numberIstrue = (rule: any, value: any) => {
  178. if (!value) {
  179. return Promise.reject(new Error('请输入正确的值'));
  180. } else {
  181. return Promise.resolve();
  182. }
  183. };
  184. const formStateRules = {
  185. PricedPrice: [{ required: true, validator: numberIstrue, trigger: 'blur', type: 'number' }],
  186. PricedQty: [{ required: true, validator: numberIstrue, trigger: 'blur', type: 'number' }],
  187. };
  188. function submit() {
  189. const wrapEl = unref(formRef);
  190. wrapEl.validate().then(() => {
  191. loading.value = true;
  192. console.log(objectToUint8Array(formState));
  193. operationContractReq({
  194. OperateType: 1, // uint32 操作类型-1:登记2:确认3:拒绝4:撤销
  195. Info: {
  196. OperateApplyType: 1, // uint32 操作申请类型-1:点价2:结算3:款项4:发票
  197. RelatedID: Long.fromString(props.selectedRow.spotcontractid), // uint64 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
  198. DetailJson: objectToUint8Array(formState), // bytes 明细JSON {}
  199. },
  200. })
  201. .then(() => {
  202. message.success('登记成功!');
  203. loading.value = false;
  204. cancel();
  205. })
  206. .catch((err) => {
  207. message.error(err);
  208. loading.value = false;
  209. cancel();
  210. });
  211. });
  212. }
  213. return {
  214. visible,
  215. cancel,
  216. submit,
  217. loading,
  218. formRef,
  219. formState,
  220. formatValue,
  221. formStateRules,
  222. getPriceTypeName,
  223. };
  224. },
  225. });
  226. </script>
  227. <style lang="less">
  228. .someprice {
  229. .ant-modal-content {
  230. .ant-modal-body {
  231. padding: 24px;
  232. }
  233. }
  234. .itemTip {
  235. position: absolute;
  236. color: @m-grey1;
  237. }
  238. legend {
  239. width: auto;
  240. margin-left: 20px;
  241. font-size: 16px;
  242. color: @m-white0;
  243. border-bottom: 0;
  244. padding: 0 10px;
  245. }
  246. }
  247. </style>;