index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <!-- 重新提交现货合同-->
  3. <a-modal class="commonModal modify-custom" title="重新提交现货合同" v-if="visible" v-model:visible="visible" @cancel="cancel" centered width="890px">
  4. <template #footer>
  5. <a-button key="submit" type="primary" :loading="loading" :disabled="loading" @click="submit">完成</a-button>
  6. </template>
  7. <a-form class="inlineForm" ref="formRef" :model="formState" :rules="rules">
  8. <fieldset class="formFieldSet">
  9. <legend>基本信息</legend>
  10. <a-row :gutter="24">
  11. <a-col :span="12">
  12. <a-form-item label="合同编号" name="ContractNo">
  13. <a-input class="dialogInput" style="width: 200px" v-model:value="formState.ContractNo" placeholder="请输入合同编号" />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :span="12">
  17. <a-form-item label="合同类型" name="ContractType">
  18. <a-select class="inlineFormSelect" style="width: 200px" @change="contractChange" v-model:value="formState.ContractType" placeholder="请选择合同类型">
  19. <a-select-option v-for="item in contractType" :key="item.key" :value="item.key">
  20. {{ item.value }}
  21. </a-select-option>
  22. </a-select>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :span="12">
  26. <a-form-item label="业务类型" name="BizType">
  27. <a-select class="inlineFormSelect" style="width: 200px" v-model:value="formState.BizType" placeholder="请选择业务类型">
  28. <a-select-option v-for="item in businessType" :key="item.key" :value="item.key">
  29. {{ item.value }}
  30. </a-select-option>
  31. </a-select>
  32. </a-form-item>
  33. </a-col>
  34. <template v-if="isSell">
  35. <a-col :span="12">
  36. <a-form-item label="采购方" name="BuyUserID">
  37. <a-select class="inlineFormSelect" style="width: 200px" v-model:value="formState.BuyUserID" placeholder="请选择客户">
  38. <!-- 客户资料列表 正常 -->
  39. <a-select-option :value="item.userid" v-for="item in customList" :key="item.userid">
  40. {{ item.customername }}
  41. </a-select-option>
  42. </a-select>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :span="12">
  46. <a-form-item label="销售方">
  47. <span class="white">{{ getUserName() }}</span>
  48. </a-form-item>
  49. </a-col>
  50. </template>
  51. <template v-else>
  52. <a-col :span="12">
  53. <a-form-item label="采购方">
  54. <span class="white">{{ getUserName() }}</span>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :span="12">
  58. <a-form-item label="销售方" name="SellUserID">
  59. <a-select class="inlineFormSelect" v-model:value="formState.SellUserID" style="width: 200px" placeholder="请选择客户">
  60. <!-- 客户资料列表 正常 -->
  61. <a-select-option :value="item.userid" v-for="item in customList" :key="item.userid">
  62. {{ item.customername }}
  63. </a-select-option>
  64. </a-select>
  65. </a-form-item>
  66. </a-col>
  67. </template>
  68. <a-col :span="12">
  69. <a-form-item label="合同附件" name="ContractAttachment">
  70. <UploadImg :visible="visible" :imgList="uploadImgList" @upload="uploadImgAction" />
  71. </a-form-item>
  72. </a-col>
  73. <a-col :span="12">
  74. <a-form-item label="交易主体" name="SubjectID">
  75. <a-select class="inlineFormSelect" style="width: 200px" v-model:value="formState.SubjectID" placeholder="请选择主体">
  76. <a-select-option :value="item.subjectid" v-for="item in subjectList" :key="item.subjectid">
  77. {{ item.subjectname }}
  78. </a-select-option>
  79. </a-select>
  80. </a-form-item>
  81. </a-col>
  82. </a-row>
  83. </fieldset>
  84. <fieldset class="formFieldSet">
  85. <legend>现货信息</legend>
  86. <a-row :gutter="24">
  87. <a-col :span="12">
  88. <a-form-item label="现货品种" name="DeliveryGoodsID">
  89. <a-select class="inlineFormSelect" style="width: 200px" @change="deliveryGoodsChange" v-model:value="formState.DeliveryGoodsID" placeholder="请选择现货品种">
  90. <a-select-option v-for="item in deliveryGoodsList" :key="item.deliverygoodsid" :value="item.deliverygoodsid">
  91. {{ item.deliverygoodsname }}
  92. </a-select-option>
  93. </a-select>
  94. </a-form-item>
  95. </a-col>
  96. <a-col :span="12">
  97. <a-form-item label="商品" name="WrStandardID">
  98. <a-select class="inlineFormSelect" style="width: 200px" @change="WrStandardChange" v-model:value="formState.WrStandardID" placeholder="请选择商品">
  99. <a-select-option v-for="item in wrstandardList" :key="item.wrstandardid" :value="item.wrstandardid">
  100. {{ item.wrstandardname }}
  101. </a-select-option>
  102. </a-select>
  103. </a-form-item>
  104. </a-col>
  105. <a-col :span="12">
  106. <a-form-item label="品牌" name="SpotGoodsBrandID">
  107. <a-select class="inlineFormSelect" style="width: 200px" v-model:value="formState.SpotGoodsBrandID" placeholder="请选择品牌">
  108. <a-select-option v-for="item in barandList" :key="item.brandid" :value="item.brandid">
  109. {{ item.brandname }}
  110. </a-select-option>
  111. </a-select>
  112. </a-form-item>
  113. </a-col>
  114. <a-col :span="12">
  115. <a-form-item label="商品规格" name="SpotGoodsDesc">
  116. <a-input class="dialogInput" style="width: 200px" v-model:value="formState.SpotGoodsDesc" placeholder="请输入商品规格" />
  117. </a-form-item>
  118. </a-col>
  119. </a-row>
  120. </fieldset>
  121. <fieldset class="formFieldSet">
  122. <legend>价格信息</legend>
  123. <a-row :gutter="24">
  124. <a-col :span="12">
  125. <a-form-item label="定价类型" name="PriceType">
  126. <a-select class="inlineFormSelect" style="width: 200px" v-model:value="formState.PriceType" placeholder="请选择定价类型">
  127. <a-select-option v-for="item in priceType" :key="item.key" :value="item.key">
  128. {{ item.value }}
  129. </a-select-option>
  130. </a-select>
  131. </a-form-item>
  132. </a-col>
  133. <a-col :span="12">
  134. <a-form-item label="结算币种" name="CurrencyID">
  135. <a-select class="inlineFormSelect" v-model:value="formState.CurrencyID" style="width: 200px" placeholder="请选择结算币种">
  136. <a-select-option v-for="item in payCurrency" :key="item.enumitemname" :value="item.enumitemname">
  137. {{ item.enumdicname }}
  138. </a-select-option>
  139. </a-select>
  140. </a-form-item>
  141. </a-col>
  142. <a-col :span="12">
  143. <a-form-item label="数量" name="Qty">
  144. <a-input class="dialogInput suffixGrey" v-model:value="formState.Qty" style="width: 200px" @change="getAmout" placeholder="请输入数量" :suffix="numberUnit" />
  145. </a-form-item>
  146. </a-col>
  147. <a-col :span="12" v-if="formState.PriceType === 3">
  148. <a-form-item label="暂定价">
  149. <a-input class="dialogInput suffixGrey" style="width: 200px" :suffix="payCurrencyUnit" placeholder="请输入暂定价" />
  150. </a-form-item>
  151. </a-col>
  152. <!-- 以下是点价的价格信息 start -->
  153. <template v-if="formState.PriceType === 2 || formState.PriceType === 3">
  154. <a-col :span="12">
  155. <a-form-item label="点价合约" name="GoodsID">
  156. <a-select class="inlineFormSelect" v-model:value="formState.GoodsID" style="width: 200px" placeholder="请选择点价合约">
  157. <a-select-option v-for="item in goodsList" :key="item.goodsid" :value="item.goodsid">
  158. {{ item.goodsname }}
  159. </a-select-option>
  160. </a-select>
  161. </a-form-item>
  162. </a-col>
  163. <a-col :span="12">
  164. <a-form-item label="升贴水" name="PriceMove">
  165. <a-input-number class="dialogInput suffixGrey" v-model:value="formState.PriceMove" placeholder="请输入升贴水" :min="0" :suffix="`${payCurrencyUnit}/${numberUnit}`" style="width: 200px" />
  166. </a-form-item>
  167. </a-col>
  168. <a-col :span="12">
  169. <a-form-item label="点价期">
  170. <a-range-picker v-model:value="priceDate" class="commonPicker" :disabled-date="disabledDate" style="width: 200px" :show-time="{ hideDisabledOptions: true }" format="YYYY-MM-DD" />
  171. </a-form-item>
  172. </a-col>
  173. <a-col :span="12">
  174. <a-form-item label="交收期">
  175. <a-range-picker v-model:value="deliveryDate" class="commonPicker" style="width: 200px" :disabled-date="disabledDate" :show-time="{ hideDisabledOptions: true }" format="YYYY-MM-DD" />
  176. </a-form-item>
  177. </a-col>
  178. </template>
  179. <!-- 以上是点价的价格信息 end -->
  180. <template v-if="formState.PriceType === 1">
  181. <a-col :span="12">
  182. <a-form-item label="价格" name="Price">
  183. <a-input class="dialogInput suffixGrey" v-model:value="formState.Price" @change="getAmout" placeholder="请输入价格" :suffix="`${payCurrencyUnit}/${numberUnit}`" style="width: 200px" />
  184. </a-form-item>
  185. </a-col>
  186. <a-col :span="12">
  187. <a-form-item label="金额" class="relative" name="Amount">
  188. <a-input class="dialogInput suffixGrey" v-model:value="formState.Amount" readonly placeholder="输入数量和价格后自动算" :suffix="payCurrencyUnit" style="width: 200px" />
  189. </a-form-item>
  190. </a-col>
  191. <a-col :span="24">
  192. <a-form-item label="交收期">
  193. <a-range-picker v-model:value="deliveryDate" style="width: 200px" class="commonPicker" :disabled-date="disabledDate" :show-time="{ hideDisabledOptions: true }" format="YYYY-MM-DD" />
  194. </a-form-item>
  195. </a-col>
  196. </template>
  197. </a-row>
  198. </fieldset>
  199. <fieldset class="formFieldSet">
  200. <legend>其他信息</legend>
  201. <a-row :gutter="24">
  202. <a-col :span="12">
  203. <a-form-item label="保证金" name="ContractMargin">
  204. <a-input class="dialogInput suffixGrey" placeholder="请输入保证金" v-model:value="formState.ContractMargin" style="width: 200px" :suffix="payCurrencyUnit" />
  205. </a-form-item>
  206. </a-col>
  207. <a-col :span="12">
  208. <a-form-item label="业务员" name="SaleUserID">
  209. <a-select class="inlineFormSelect" v-model:value="formState.SaleUserID" style="width: 200px" placeholder="请选择业务员">
  210. <a-select-option v-for="item in businesserList" :key="item.userid" :value="item.userid"> {{ item.accountname }}-{{ item.logincode }} </a-select-option>
  211. </a-select>
  212. </a-form-item>
  213. </a-col>
  214. </a-row>
  215. <a-row :gutter="24">
  216. <a-col :span="12">
  217. <a-form-item label="跟单员" name="MerUserID">
  218. <a-select class="inlineFormSelect" v-model:value="formState.MerUserID" style="width: 200px" placeholder="请选择跟单员">
  219. <a-select-option v-for="item in merchandiserList" :key="item.userid" :value="item.userid"> {{ item.accountname }}-{{ item.logincode }} </a-select-option>
  220. </a-select>
  221. </a-form-item>
  222. </a-col>
  223. <a-col :span="12">
  224. <a-form-item label="交易用户" name="TradeUserID">
  225. <a-select class="inlineFormSelect" style="width: 200px" v-model:value="formState.TradeUserID" placeholder="请选择期货账户">
  226. <a-select-option v-for="item in traderList" :key="item.roleid" :value="item.roleid">
  227. {{ item.rolename }}
  228. </a-select-option>
  229. </a-select>
  230. </a-form-item>
  231. </a-col>
  232. </a-row>
  233. <a-row :gutter="24">
  234. <a-col :span="24">
  235. <a-form-item label="备注" name="Remark">
  236. <a-input class="dialogInput" style="width: 608px" v-model:value="formState.Remark" placeholder="请输入备注" />
  237. </a-form-item>
  238. </a-col>
  239. </a-row>
  240. </fieldset>
  241. </a-form>
  242. <a-modal :visible="previewVisible" :footer="null" @cancel="cancelImg">
  243. <img alt="预览附件" style="width: 100%" :src="previewImage" />
  244. </a-modal>
  245. </a-modal>
  246. </template>
  247. <script lang="ts">
  248. import { defineComponent, PropType, ref } from 'vue';
  249. import { getUserName, getUserId } from '@/services/bus/user';
  250. import { FormState } from '../interface';
  251. import { formatTime } from '@/common/methods/format';
  252. import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
  253. import moment, { Moment } from 'moment';
  254. import { handleFormRule, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, handleFromState } from '../setup';
  255. import { addContractReq } from '@/views/information/spot-contract/components/add/setup';
  256. import { mergeTwoObj } from '@/utils/objHandle';
  257. import { validateAction } from '@/common/setup/form';
  258. import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface';
  259. import { Ermcp3SubjectRsp } from '@/services/go/ermcp/subject/interface';
  260. import { QueryPaAreaSubject } from '@/services/go/ermcp/subject';
  261. import { handlerManagerList } from '@/common/setup/user';
  262. import { getUploadImg } from '@/common/setup/upload';
  263. import UploadImg from '@/common/components/uploadImg/index.vue';
  264. import { _closeModal } from '@/common/setup/modal/modal';
  265. export default defineComponent({
  266. name: 'spot_contract_btn_modify',
  267. emits: ['cancel', 'update'],
  268. props: {
  269. selectedRow: {
  270. type: Object as PropType<Ermcp3ContractRsp>,
  271. default: {},
  272. },
  273. contractType: {
  274. type: Number,
  275. required: true,
  276. },
  277. },
  278. components: { UploadImg },
  279. setup(props, context) {
  280. const { visible, cancel } = _closeModal(context);
  281. const loading = ref<boolean>(false);
  282. const { sendReq } = addContractReq();
  283. const { formState, businessType } = handleFromState(props.contractType);
  284. // 表单
  285. const formRef = ref();
  286. const { rules } = handleFormRule(formState);
  287. // 合同类型
  288. const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract(formState);
  289. // 处理现货商品
  290. const { deliveryGoodsList, barandList, wrstandardList, goodsList, numberUnit, WrStandardChange, deliveryGoodsChange } = handleDeliveryGoods(formState);
  291. // 价格信息
  292. const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
  293. // 日期
  294. const { deliveryDate, priceDate, disabledDate } = handleDate();
  295. // 处理金额
  296. const { getAmout } = handleAmout(formState);
  297. // 获取 业务账户
  298. const { queryTable: queryBusinessManager, getBusinesserOrMerchandiser } = handlerManagerList(loading, 1);
  299. const { tableList: traderList, queryTable: queryTradeManager } = handlerManagerList(loading, 2, true);
  300. // 业务员
  301. const businesserList = ref<ErmcpLoginUser[]>([]);
  302. // 跟单员
  303. const merchandiserList = ref<ErmcpLoginUser[]>([]);
  304. queryBusinessManager().then(() => {
  305. businesserList.value = getBusinesserOrMerchandiser('22');
  306. merchandiserList.value = getBusinesserOrMerchandiser('23');
  307. });
  308. // 交易主体列表
  309. const subjectList = ref<Ermcp3SubjectRsp[]>([]);
  310. QueryPaAreaSubject().then((res) => {
  311. subjectList.value = res;
  312. });
  313. const { uploadImgAction, uploadImgList, handleImg } = getUploadImg();
  314. queryCustomList();
  315. queryTradeManager();
  316. mergeTwoObj(formState, props.selectedRow);
  317. isSell.value = formState.ContractType === 1 ? false : true;
  318. const { deliverygoodsid, qty, price, wrstandardid, spotcontractid, spotgoodsbrandid, currencyid, attachment, deliverystartdate, deliveryenddate, startdate, enddate, meruserid, tradeuserid } = props.selectedRow;
  319. if (deliverygoodsid) {
  320. deliveryGoodsChange(deliverygoodsid);
  321. if (wrstandardid) {
  322. WrStandardChange(wrstandardid);
  323. formState.WrStandardID = wrstandardid;
  324. formState.SpotGoodsBrandID = spotgoodsbrandid;
  325. }
  326. }
  327. formState.Qty = qty.toString();
  328. formState.Price = price.toString();
  329. formState.CurrencyID = currencyid;
  330. formState.ContractAttachment = attachment;
  331. formState.MerUserID = meruserid;
  332. formState.TradeUserID = tradeuserid;
  333. formState.SpotContractID = spotcontractid;
  334. if (deliverystartdate && deliverystartdate !== '--') {
  335. deliveryDate.value.push(moment(deliverystartdate));
  336. }
  337. if (deliveryenddate && deliveryenddate !== '--') {
  338. deliveryDate.value.push(moment(deliveryenddate));
  339. }
  340. if (startdate && startdate !== '--') {
  341. priceDate.value.push(moment(startdate));
  342. }
  343. if (enddate && enddate !== '--') {
  344. priceDate.value.push(moment(enddate));
  345. }
  346. if (attachment) {
  347. uploadImgList.value = handleImg(attachment);
  348. }
  349. function submit() {
  350. validateAction<FormState>(formRef, formState).then((param) => {
  351. const id = getUserId();
  352. isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
  353. const fn = (value: Moment) => {
  354. return formatTime(value, 'd') + ' ' + '00:00:00';
  355. };
  356. // 交收期
  357. const dDate = deliveryDate.value;
  358. if (dDate.length) {
  359. const DeliveryStartDate = fn(dDate[0]);
  360. const DeliveryEndDate = fn(dDate[1]);
  361. Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
  362. }
  363. // 点价期
  364. const pDate = priceDate.value;
  365. if (pDate.length && param.PriceType !== 1) {
  366. // 点价日期[2:点价3:暂定价]
  367. const StartDate = fn(pDate[0]);
  368. const EndDate = fn(pDate[1]);
  369. Object.assign(param, { StartDate, EndDate });
  370. }
  371. sendReq(param, loading, 2)
  372. .then((res) => {
  373. cancel(true);
  374. })
  375. .catch((err) => {});
  376. });
  377. }
  378. return {
  379. visible,
  380. cancel,
  381. submit,
  382. formRef,
  383. loading,
  384. maskClosableFlag: false,
  385. formState,
  386. rules,
  387. businessType,
  388. contractType,
  389. isSell,
  390. contractChange,
  391. customList,
  392. deliveryGoodsList,
  393. barandList,
  394. wrstandardList,
  395. goodsList,
  396. deliveryGoodsChange,
  397. WrStandardChange,
  398. priceType,
  399. payCurrency,
  400. payCurrencyUnit,
  401. parCurrencyChange,
  402. numberUnit,
  403. getUserName,
  404. deliveryDate,
  405. priceDate,
  406. disabledDate,
  407. getAmout,
  408. traderList,
  409. businesserList,
  410. merchandiserList,
  411. uploadImgAction,
  412. uploadImgList,
  413. subjectList,
  414. };
  415. },
  416. });
  417. </script>