detailDialog.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <!-- 列表选择弹窗 -->
  3. <f-dialog
  4. ref="dialog"
  5. title="基础库配置信息"
  6. :initData="handleInitData"
  7. :isDetermine="dialogType!=='detail'"
  8. :beforeClose="handleBeforeClose"
  9. width="1100px"
  10. >
  11. <template #contain>
  12. <f-form
  13. ref="ruleForm"
  14. :form="fromData"
  15. :disabled="dialogType==='detail'"
  16. :config="fromDataConfig"
  17. :rules="fromRules"
  18. label-position="left"
  19. :column="2"
  20. :key="fromKey"
  21. />
  22. </template>
  23. </f-dialog>
  24. </template>
  25. <script>
  26. import { addBaseApi } from '@/api/base/addBase'
  27. export default {
  28. name: "DetailDialog",
  29. props: {
  30. // 表单数据
  31. rowData:{
  32. type:Object,
  33. default:()=>{}
  34. },
  35. // 表单类型 add detail edit
  36. dialogType:{
  37. type:String,
  38. default:'add'
  39. }
  40. },
  41. data() {
  42. return {
  43. // 数据对象
  44. fromData:{
  45. },
  46. // 表单配置
  47. fromDataConfig:[
  48. {
  49. itemType: "input",
  50. prop: "name",
  51. label:'基础库名',
  52. attrs: {
  53. placeholder: "请输入基础库名"
  54. },
  55. },
  56. {
  57. itemType: "input",
  58. prop: "bandValue",
  59. label:'波段值',
  60. attrs: {
  61. inputType:'Number',
  62. placeholder: "请输入波段值,默认38000"
  63. },
  64. },
  65. {
  66. itemType: "input",
  67. prop: "repeatCode",
  68. label:'重复码',
  69. attrs: {
  70. placeholder: "请输入重复码"
  71. },
  72. },
  73. {
  74. itemType: "input",
  75. prop: "bootCode",
  76. label:'引导码',
  77. attrs: {
  78. placeholder: "请输入引导码"
  79. },
  80. },
  81. {
  82. itemType: "input",
  83. prop: "bootCodeSend",
  84. label:'引导码发送次数',
  85. attrs: {
  86. inputType:'Number',
  87. placeholder: "请输入引导码发送次数"
  88. },
  89. },
  90. {
  91. itemType: "input",
  92. prop: "synchronizeCode",
  93. label:'同步码',
  94. attrs: {
  95. placeholder: "请输入同步码"
  96. },
  97. },
  98. {
  99. itemType: "input",
  100. prop: "synchronizeCodeSend",
  101. label:'同步码发送次数',
  102. attrs: {
  103. inputType:'Number',
  104. placeholder: "请输入同步码发送次数"
  105. },
  106. },
  107. {
  108. itemType: "input",
  109. prop: "dateCode",
  110. label:'数据',
  111. attrs: {
  112. placeholder: "请输入数据",
  113. span:2,
  114. type:'textarea'
  115. },
  116. },
  117. {
  118. itemType: "input",
  119. prop: "overCode",
  120. label:'结束码',
  121. attrs: {
  122. placeholder: "请输入结束码"
  123. },
  124. },
  125. {
  126. itemType: "input",
  127. prop: "dateBinary0",
  128. label:'数据二进制0',
  129. attrs: {
  130. placeholder: "请输入数据二进制0"
  131. },
  132. },
  133. {
  134. itemType: "input",
  135. prop: "dateBinary1",
  136. label:'数据二进制1',
  137. attrs: {
  138. placeholder: "请输入数据二进制1"
  139. },
  140. }
  141. ],
  142. // 表单验证
  143. fromRules:{
  144. name:[{required: true, message: '请输入基础库名'}],
  145. bootCode:[{required: true, message: '请输入引导码'}],
  146. bootCodeSend:[{required: true, message: '请输入引导码发送次数'}],
  147. dateCode:[{required: true, message: '请输入数据'}],
  148. overCode:[{required: true, message: '请输入结束码'}],
  149. dateBinary0:[{required: true, message: '请输入数据二进制0'}],
  150. dateBinary1:[{required: true, message: '请输入数据二进制1'}]
  151. },
  152. // 表单key
  153. fromKey:0
  154. };
  155. },
  156. methods: {
  157. // 显示弹窗
  158. show(){
  159. this.$refs.dialog.show();
  160. },
  161. // 初始化表单数据
  162. initFormData(fromData){
  163. this.fromData = {
  164. content:'',
  165. ...fromData
  166. }
  167. this.fromKey++;
  168. },
  169. // 详情
  170. async handleInitData(){
  171. const {dialogType,rowData} = this;
  172. if(dialogType === 'add') return this.initFormData({})
  173. // 调接口获取详情
  174. const res = await addBaseApi.configDetail({ id: rowData.id });
  175. if(res.code != 200) return this.initFormData({})
  176. const from = { ...res.data }
  177. this.initFormData(from);
  178. },
  179. // 关闭之前回调.
  180. async handleBeforeClose(type){
  181. if(type !='ok') return true;
  182. const validate = await this.$refs.ruleForm.validate();
  183. if(!validate) return false;
  184. const params = {
  185. ...this.fromData,
  186. // bandValue: Number(this.fromData.bandValue),
  187. // bootCodeSend: Number(this.fromData.bootCodeSend)
  188. }
  189. // 调接口更新数据
  190. const res = await addBaseApi.configAddOrEdit(params);
  191. if(res.code !=200){
  192. this.$modal.msgError(res.msg);
  193. return false;
  194. }
  195. this.$emit('updateList')
  196. this.initFormData({})
  197. return true;
  198. }
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss"></style>