productArchiveModel.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <a-modal
  3. :title="title"
  4. width="80%"
  5. :visible="visible"
  6. :maskClosable="false"
  7. switchFullscreen
  8. @ok = "handleOk"
  9. @cancel="handleCancel">
  10. <a-spin :spinning="loading">
  11. <!-- 主表单区域 -->
  12. <a-form ref="formRef" :model="model" :rules="validatorRules">
  13. <a-row :gutter="24">
  14. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  15. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classId" label="分类(class)">
  16. <ApiSelect
  17. :api="classOption"
  18. :showSearch="true"
  19. v-model:value="model.classId"
  20. :filterOption="true"
  21. resultField="records"
  22. labelField="name"
  23. valueField="id"
  24. optionFilterProp='label'
  25. />
  26. </a-form-item>
  27. </a-col>
  28. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  29. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="code" label="编码(code)">
  30. <a-input placeholder="自动生成" v-model:value="model.code" AutoComplete='off' disabled/>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  34. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chineseName" label="中文名(Chinese name)">
  35. <a-input placeholder="请输入" v-model:value="model.chineseName" AutoComplete='off' @blur="handleBlur(model.chineseName,'chineseName')"/>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  39. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="englishName" label="英文名(English name)">
  40. <a-input placeholder="请输入" v-model:value="model.englishName" AutoComplete='off' @blur="handleBlur(model.englishName,'englishName')"/>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  44. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chineseAlias" label="中文别名(Chinese allas)">
  45. <a-input placeholder="请输入" v-model:value="model.chineseAlias" AutoComplete='off' @blur="handleBlur(model.chineseAlias,'chineseAlias')"/>
  46. </a-form-item>
  47. </a-col>
  48. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  49. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="englishAlias" label="英文别名(englidsh allas)">
  50. <a-input placeholder="请输入" v-model:value="model.englishAlias" AutoComplete='off' @blur="handleBlur(model.englishAlias,'englishAlias')"/>
  51. </a-form-item>
  52. </a-col>
  53. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  54. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="model" label="型号(model)">
  55. <JDictSelectTag v-model:value="model.model" placeholder="请选择" dictCode="model_typer" showSearch/>
  56. </a-form-item>
  57. </a-col>
  58. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  59. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partno" label="备件号(partno)">
  60. <a-input placeholder="请输入" v-model:value="model.partno" AutoComplete='off'/>
  61. </a-form-item>
  62. </a-col>
  63. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  64. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderno" label="订货号(orderno)">
  65. <a-input placeholder="请输入" v-model:value="model.orderno" AutoComplete='off'/>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  69. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="drawingno" label="图号(drawingno)">
  70. <a-input placeholder="请输入" v-model:value="model.drawingno" AutoComplete='off'/>
  71. </a-form-item>
  72. </a-col>
  73. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  74. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taxRate" label="税率(tax rate)">
  75. <a-input placeholder="请输入" v-model:value="model.taxRate" AutoComplete='off' addon-after="%"/>
  76. </a-form-item>
  77. </a-col>
  78. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  79. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="measurementUnit" label="计量单位(measurement unit)">
  80. <JDictSelectTag v-model:value="model.measurementUnit" placeholder="请选择" dictCode="measurement_unit"/>
  81. </a-form-item>
  82. </a-col>
  83. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  84. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="harmfulSubstances" label="有害物质(harmful substances)">
  85. <JDictSelectTag v-model:value="model.harmfulSubstances" placeholder="请选择" dictCode="yes_or_no" stringToNumber/>
  86. </a-form-item>
  87. </a-col>
  88. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  89. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="virtualProduct" label="虚拟产品(virtual product)">
  90. <JDictSelectTag v-model:value="model.virtualProduct" placeholder="请选择" dictCode="yes_or_no" stringToNumber/>
  91. </a-form-item>
  92. </a-col>
  93. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  94. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="commissionRebate" label="返佣(commission rebate)">
  95. <JDictSelectTag v-model:value="model.commissionRebate" placeholder="请选择" dictCode="yes_or_no" stringToNumber/>
  96. </a-form-item>
  97. </a-col>
  98. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  99. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="notes" label="备注(notes)">
  100. <a-input placeholder="请输入" v-model:value="model.notes" AutoComplete='off'/>
  101. </a-form-item>
  102. </a-col>
  103. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  104. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status" label="状态(status)">
  105. <JDictSelectTag v-model:value="model.status" placeholder="请选择" dictCode="valid_status" stringToNumber/>
  106. </a-form-item>
  107. </a-col>
  108. </a-row>
  109. </a-form>
  110. </a-spin>
  111. </a-modal>
  112. </template>
  113. <script lang="ts" setup>
  114. import { defHttp } from '/@/utils/http/axios';
  115. import { message } from 'ant-design-vue';
  116. import { JDictSelectTag,JSearchSelect,ApiSelect} from '/@/components/Form';
  117. import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  118. import { ref, reactive, toRaw, toRefs, watch, nextTick, onMounted, getCurrentInstance } from 'vue';
  119. const emit = defineEmits([ 'success']); //定义emit
  120. const formRef = ref()
  121. var visible = ref(false)
  122. let title = ref('')
  123. let loading = ref(false)
  124. let model = ref({
  125. classId:'',
  126. code:'',
  127. chineseName:'',
  128. englishName:'',
  129. chineseAlias:'',
  130. englishAlias:'',
  131. model:'',
  132. partno:'',
  133. orderno:'',
  134. drawingno:'',
  135. taxRate:'0',
  136. harmfulSubstances:0,
  137. virtualProduct:0,
  138. commissionRebate:1,
  139. notes:'',
  140. status:1,
  141. measurementUnit:'PCE',
  142. id:''
  143. })
  144. let enforcemmentBasis = ref('')
  145. const validatorRules = {
  146. // code: [{ required: true, message: '编码(code)不能为空', trigger: 'blur' }],
  147. englishName: [{ required: true, message: '英文名(english name)不能为空', trigger: 'blur' }],
  148. };
  149. const labelCol = ref({
  150. xs: { span: 24 },
  151. sm: { span: 9 },
  152. });
  153. const wrapperCol = ref({
  154. xs: { span: 24 },
  155. sm: { span: 15 },
  156. });
  157. function handleOk() {
  158. formRef.value
  159. .validate()
  160. .then(async () => {
  161. let url = ''
  162. if(enforcemmentBasis.value=='add'){
  163. url = '/baseCode/baseProductArchive/add'
  164. }else{
  165. url = '/baseCode/baseProductArchive/edit'
  166. }
  167. let params = model.value
  168. defHttp.post({url,params}, { isTransformResponse: false })
  169. .then((res) => {
  170. if (res.success) {
  171. message.success(res.message);
  172. } else {
  173. message.error(res.message);
  174. }
  175. })
  176. .finally(() => {
  177. handleCancel()
  178. });
  179. })
  180. .catch(error => {
  181. console.log('error', error);
  182. });
  183. }
  184. function handleCancel() {
  185. model.value ={
  186. classId:'',
  187. code:'',
  188. chineseName:'',
  189. englishName:'',
  190. chineseAlias:'',
  191. englishAlias:'',
  192. model:'',
  193. partno:'',
  194. orderno:'',
  195. drawingno:'',
  196. taxRate:'0',
  197. harmfulSubstances:0,
  198. virtualProduct:0,
  199. commissionRebate:1,
  200. notes:'',
  201. status:1,
  202. measurementUnit:'PCE',
  203. id:''
  204. }
  205. visible.value = false
  206. emit('success');
  207. }
  208. function getForm(data,record){
  209. enforcemmentBasis.value = data
  210. visible.value = true
  211. if(data=='add'){
  212. title.value = '新增档案(add)'
  213. }else{
  214. title.value = '编辑档案(edit)'
  215. model.value = record
  216. }
  217. }
  218. function classOption(){
  219. var params = {pageSize:-1}
  220. return defHttp.get({ url: 'baseCode/baseProductClass/list',params})
  221. }
  222. function handleBlur(value,data){
  223. if(value!==''){
  224. var newString = ''
  225. for (let i = 0; i < value.length; i++) {
  226. if( (/^[A-Za-z]$/.test(value[i]))&&(/^[a-z]$/.test(value[i]))){
  227. newString=newString+value[i].toUpperCase()
  228. }else{
  229. newString =newString+value[i]
  230. }
  231. }
  232. model.value[data] = newString
  233. }
  234. }
  235. defineExpose({
  236. getForm
  237. });
  238. </script>
  239. <style lang="less" scoped>
  240. /deep/ .ant-spin-container{
  241. width: 97%;
  242. margin-top: 1%;
  243. }
  244. /deep/.ant-form-item {
  245. margin-bottom: 8px !important;
  246. }
  247. </style>