index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <!-- 修改仓库信息-->
  3. <a-modal class="modify-custom commonModal"
  4. title="修改仓库信息"
  5. v-model:visible="visible"
  6. centered
  7. :maskClosable="maskClosableFlag"
  8. @cancel="cancel"
  9. width="890px">
  10. <template #footer>
  11. <a-button key="submit"
  12. type="primary"
  13. :loading="loading"
  14. @click="cancel">关闭</a-button>
  15. <a-button key="submit"
  16. type="primary"
  17. :loading="loading"
  18. @click="submit">修改</a-button>
  19. </template>
  20. <a-form class="inlineForm"
  21. ref="formRef"
  22. :model="formState"
  23. :rules="rules">
  24. <a-row :gutter="24">
  25. <a-col :span="12">
  26. <a-form-item label="仓库类型"
  27. name="warehousetype">
  28. <a-select class="typeSelect"
  29. style="width: 200px"
  30. v-model:value="formState.warehousetype"
  31. placeholder="请选择仓库类型">
  32. <a-select-option v-for="item in warehouseType"
  33. :key="item.enumitemname"
  34. :value="item.enumitemname">
  35. {{item.enumdicname}}
  36. </a-select-option>
  37. </a-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="12">
  41. <a-form-item label="仓库名称"
  42. name="warehousename">
  43. <a-input class="dialogInput"
  44. style="width: 200px"
  45. v-model:value="formState.warehousename"
  46. placeholder="请输入仓库名称" />
  47. </a-form-item>
  48. </a-col>
  49. </a-row>
  50. <a-row :gutter="24">
  51. <a-col :span="12">
  52. <a-form-item label="仓库简称"
  53. name="warehousecode">
  54. <a-input class="dialogInput"
  55. style="width: 200px"
  56. v-model:value="formState.warehousecode"
  57. placeholder="请输入仓库简称" />
  58. </a-form-item>
  59. </a-col>
  60. <a-col :span="12">
  61. <a-form-item label="联系人"
  62. name="contactname">
  63. <a-input class="dialogInput"
  64. style="width: 200px"
  65. v-model:value="formState.contactname"
  66. placeholder="请输入联系人" />
  67. </a-form-item>
  68. </a-col>
  69. </a-row>
  70. <a-row :gutter="24">
  71. <a-col :span="24">
  72. <a-form-item label="联系电话"
  73. name="contactnum">
  74. <a-input class="dialogInput"
  75. style="width: 200px"
  76. v-model:value="formState.contactnum"
  77. placeholder="请输入联系电话" />
  78. </a-form-item>
  79. </a-col>
  80. </a-row>
  81. <a-row :gutter="24">
  82. <a-col :span="24">
  83. <a-form-item label="所在地区">
  84. <a-select class="inlineFormSelect"
  85. style="width: 205px"
  86. v-model:value="formState.provinceid"
  87. @change="provinceChange"
  88. placeholder="请选择省">
  89. <a-select-option v-for="item in provinceList"
  90. :key="item.autoid"
  91. :value="item.autoid">
  92. {{item.divisionname}}
  93. </a-select-option>
  94. </a-select>
  95. <a-select class="inlineFormSelect ml9"
  96. style="width: 205px"
  97. v-model:value="formState.cityid"
  98. @change="cityChange"
  99. placeholder="请选择市">
  100. <a-select-option v-for="item in cityList"
  101. :key="item.autoid"
  102. :value="item.autoid">
  103. {{item.divisionname}}
  104. </a-select-option>
  105. </a-select>
  106. <a-select class="inlineFormSelect ml9"
  107. v-model:value="formState.districtid"
  108. style="width: 205px"
  109. placeholder="请选择县(区)">
  110. <a-select-option v-for="item in districtList"
  111. :key="item.autoid"
  112. :value="item.autoid">
  113. {{item.divisionname}}
  114. </a-select-option>
  115. </a-select>
  116. </a-form-item>
  117. </a-col>
  118. </a-row>
  119. <a-row :gutter="24">
  120. <a-col :span="24">
  121. <a-form-item label="详细地址"
  122. name="address">
  123. <a-input class="dialogInput"
  124. v-model:value="formState.address"
  125. style="width: 635px"
  126. placeholder="请输入详细地址" />
  127. </a-form-item>
  128. </a-col>
  129. </a-row>
  130. </a-form>
  131. </a-modal>
  132. </template>
  133. <script lang="ts">
  134. import { defineComponent, PropType, ref, toRaw, watchEffect } from 'vue';
  135. import { closeModal } from '@/common/setup/modal/index';
  136. import { getAddress } from '@/services/go/adress';
  137. import { handleForm, FormState, warehouseApply } from '../setup';
  138. import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
  139. import { AllEnums } from '@/services/go/commonService/interface';
  140. import { WarehouseApplyReq } from '@/services/proto/warehouse/interface';
  141. import { ErmcpWareHouseInfo } from '@/services/go/ermcp/warehouse-info/interface';
  142. import { mergeTwoObj } from '@/utils/objHandle';
  143. import { getWarehouseTypeEnumList } from '@/common/constants/enumsList';
  144. export default defineComponent({
  145. name: 'warehouse_info_btn_modify',
  146. props: {
  147. selectedRow: {
  148. type: Object as PropType<ErmcpWareHouseInfo>,
  149. default: {},
  150. },
  151. },
  152. components: {},
  153. setup(props, context) {
  154. const { visible, cancel } = closeModal('warehouse_info_btn_modify');
  155. const loading = ref<boolean>(false);
  156. const { cityList, districtList, provinceList, getCityList, getDistrictList } = getAddress();
  157. const warehouseType = ref<AllEnums[]>(getWarehouseTypeEnumList());
  158. const { formRef, formState, rules } = handleForm();
  159. watchEffect(() => {
  160. if (visible.value) {
  161. mergeTwoObj(formState, props.selectedRow);
  162. const { provinceid, cityid } = props.selectedRow;
  163. provinceid ? getCityList(provinceid) : (formState.provinceid = undefined);
  164. cityid ? getDistrictList(cityid) : ((formState.cityid = undefined), (formState.districtid = undefined));
  165. }
  166. });
  167. function submit() {
  168. formRef.value
  169. .validate()
  170. .then(() => {
  171. const param = toRaw(formState);
  172. const reqParam: WarehouseApplyReq = {
  173. type: 2, // int32 类型 1 新增 2 修改
  174. warehouseid: props.selectedRow.autoid, // uint64 仓库ID
  175. warehousecode: props.selectedRow.warehousecode, // string 仓库代码
  176. warehousename: param.warehousename, // string 仓库名称
  177. warehousetype: undefined === param.warehousetype ? 0 : (param.warehousetype as number), // int32 仓库类型 - 1 厂库 2 自有库 3 合作库
  178. provinceid: undefined === param.provinceid ? 0 : (param.provinceid as number), // uint64 省
  179. cityid: undefined === param.cityid ? 0 : (param.cityid as number), // uint64 市
  180. districtid: undefined === param.districtid ? 0 : (param.districtid as number), // int32 区
  181. address: param.address, // string 详细地址
  182. contactname: param.contactname, // string 联系人
  183. contactnum: param.contactnum, // string 联系电话
  184. };
  185. warehouseApply(reqParam, loading)
  186. .then((res) => {
  187. cancel();
  188. context.emit('refresh');
  189. })
  190. .catch((err) => {});
  191. })
  192. .catch((error: ValidateErrorEntity<FormState>) => {
  193. console.log('error', error);
  194. });
  195. }
  196. function provinceChange(id: number) {
  197. getCityList(id);
  198. formState.cityid = undefined;
  199. formState.districtid = undefined;
  200. }
  201. function cityChange(id: number) {
  202. getDistrictList(id);
  203. formState.districtid = undefined;
  204. }
  205. return {
  206. visible,
  207. cancel,
  208. submit,
  209. loading,
  210. maskClosableFlag: false,
  211. cityList,
  212. districtList,
  213. provinceList,
  214. provinceChange,
  215. cityChange,
  216. formRef,
  217. formState,
  218. rules,
  219. warehouseType,
  220. };
  221. },
  222. });
  223. </script>
  224. <style lang="less">
  225. .modify-custom {
  226. }
  227. </style
  228. >;