ItemDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <table-row-detail-dialog
  3. ref="detailDialog"
  4. @confirm="handleConfirm"
  5. dialogWidth="70%"
  6. :noFooter="true"
  7. :has-form-steps-group="true"
  8. class="steps-dialog"
  9. @close="handleClose"
  10. >
  11. <div class="dialog-body">
  12. <form-steps-group
  13. ref="formGroup"
  14. label-width='150px'
  15. :list-data="newCompanyData"
  16. :parent-dialog-mode="dialogType"
  17. @change="itemChange"
  18. @submit="onSubmit"
  19. @cancel="$refs.detailDialog && $refs.detailDialog.hide()"
  20. >
  21. </form-steps-group>
  22. </div>
  23. </table-row-detail-dialog>
  24. </template>
  25. <script>
  26. import TableRowDetailDialog from "@/components/TableRowDetailDialogNew/index";
  27. import FormStepsGroup from "@/components/FormStepsGroup/index";
  28. import { add, edit, detail } from "@/api/elevator-sys-org/unit-mgt";
  29. import DetailAction from "@/views/_mixins/detail-action";
  30. import { basePath } from "@/utils/request";
  31. import { deepClone } from "@/utils/index";
  32. const defaultNewCompanyData = {
  33. type: 'steps', // type类型为 radioGroup (单选框组按钮)、steps (步骤条)
  34. stepsWidth: '264px',
  35. disableLastStepConfirm: true,
  36. data: [
  37. {
  38. title: '',
  39. formData: {
  40. organizationCode: { label: '组织机构代码', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px',required:true},
  41. companyName: { label: '单位名称', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px',required:true},
  42. companyNameShort: { label: '单位简称', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  43. companyNameEnglish: { label: '英文名称', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  44. companyTelephone: { label: '单位电话', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px',required:true},
  45. registrationDate: { label: '注册日期', value: '', placeholder: '请输入', type: 'date-picker', width: '50%', rightGap:'10px', leftGap: '10px'},
  46. companyNature: { label: '公司性质', value: '', placeholder: '请选择', type: 'select', dictKey: 'company_nature', width: '50%', rightGap:'10px', leftGap: '10px'},
  47. parentCompany: { label: '上级公司', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  48. registeredCapital: { label: '注册资金(万元)', value: '', placeholder: '请输入', type: 'number', min:0, width: '50%', rightGap:'10px', leftGap: '10px'},
  49. companyType: { label: '单位类型', value: '', placeholder: '请选择', type: 'select', dictKey:'company_type', width: '50%', rightGap:'10px', leftGap: '10px',required:true},
  50. registrationStatus: { label: '登记状态', value: '', placeholder: '请选择', type: 'select', dictKey:'registration_status', width: '50%', rightGap:'10px', leftGap: '10px',required:true},
  51. legalPerson: { label: '法人', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  52. leader: { label: '负责人名称', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  53. staffCount: { label: '员工总数', value: '', placeholder: '请输入', type: 'number', min:0, step:1, stepStrictly:true, width: '50%', rightGap:'10px', leftGap: '10px'},
  54. email: { label: '单位邮箱', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  55. postalCode: { label: '单位邮编', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  56. address: { label: '单位地址', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  57. dataStatus: { label: '单位状态', value: 1, type: 'switch', text:['启用', '禁用'], width: '50%', rightGap:'10px', leftGap: '10px'},
  58. website: { label: '单位官网', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px'},
  59. systemName: { label: '系统名称', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px', leftGap: '10px',required:true},
  60. companyLogo: { label: '单位Logo', value: '', actionUrl: basePath + 'common/file', type: 'singleImgUpload', width: '50%', rightGap: '10px', leftGap: '10px'},
  61. attachmentFileUrl: { label: '单位附件', value: '', type: 'uploadFormItem', actionUrl: "datarecord/file", width: '100%', rightGap:'10px', leftGap: '10px'},
  62. businessScope: { label: '经营范围', value: '', placeholder: '请输入', type: 'textarea', width: '100%', rightGap:'10px', leftGap: '10px'},
  63. }
  64. },
  65. {
  66. title: '',
  67. formData: {
  68. }
  69. }
  70. ],
  71. }
  72. export default {
  73. name: "ItemDetail",
  74. mixins: [DetailAction],
  75. components: {
  76. TableRowDetailDialog,
  77. FormStepsGroup,
  78. },
  79. props: {},
  80. data() {
  81. return {
  82. companyId: "",
  83. fileName: "",
  84. newCompanyData: deepClone(defaultNewCompanyData),
  85. preparingData: false,
  86. };
  87. },
  88. watch: {
  89. currentCompanyType: {
  90. handler(val) {
  91. if (!this.preparingData) {
  92. let formData = this.getSecondFormData(val);
  93. this.$set(this.newCompanyData.data[1],'formData', formData);
  94. }
  95. }
  96. }
  97. },
  98. computed: {
  99. currentCompanyType() {
  100. return this.newCompanyData.data[0].formData.companyType.value;
  101. }
  102. },
  103. created() {},
  104. methods: {
  105. handleClose() {
  106. for (let i=0; i<this.$refs.formGroup.$refs.formGroup.length; i++) {
  107. this.$refs.formGroup.$refs.formGroup[i].editMode= 'add';
  108. }
  109. },
  110. getSecondFormData(val) {
  111. let formData = null;
  112. if (val==='mainten') {
  113. formData = {
  114. licenseNumber: { label: '许可证编号', value: '', placeholder: '请输入', type: 'input', width: '100%' },
  115. licenseApprovalCompany: { label: '许可证审批单位', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px' },
  116. licenseIssueCompany: { label: '许可证签发单位', value: '', placeholder: '请输入', type: 'input', width: '50%', leftGap: '10px'},
  117. licenseIssueDate: { label: '许可证签发日期', value: '', placeholder: '请输入', type: 'date-picker', width: '50%', rightGap:'10px' },
  118. licenseExpireDate: { label: '许可证到期日期', value: '', placeholder: '请输入', type: 'date-picker', width: '50%', leftGap: '10px'},
  119. description: { label: '备注', value: '', placeholder: '请输入', type: 'textarea', width: '100%' },
  120. platformUserName: { hasHeadDivider:true, headDividerTitle: '智慧特种设备信息', label: '平台UserName', value: '', placeholder: '请输入', type: 'text', width: '50%', rightGap:'10px' },
  121. platformKey: { label: '平台Key', value: '', placeholder: '请输入', type: 'input', width: '50%', leftGap: '10px' },
  122. platformAppCode: { label: '平台AppCode', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px' },
  123. platformSecret: { label: '平台Secret', value: '', placeholder: '请输入', type: 'input', width: '50%', leftGap: '10px' },
  124. };
  125. } else if (val==='insure') {
  126. formData = {
  127. description: { label: '备注', value: '', placeholder: '请输入', type: 'textarea', width: '100%' },
  128. }
  129. } else {
  130. formData = {
  131. licenseNumber: { label: '许可证编号', value: '', placeholder: '请输入', type: 'input', width: '100%' },
  132. licenseApprovalCompany: { label: '许可证审批单位', value: '', placeholder: '请输入', type: 'input', width: '50%', rightGap:'10px' },
  133. licenseIssueCompany: { label: '许可证签发单位', value: '', placeholder: '请输入', type: 'input', width: '50%', leftGap: '10px'},
  134. licenseIssueDate: { label: '许可证签发日期', value: '', placeholder: '请输入', type: 'date-picker', width: '50%', rightGap:'10px' },
  135. licenseExpireDate: { label: '许可证到期日期', value: '', placeholder: '请输入', type: 'date-picker', width: '50%', leftGap: '10px'},
  136. description: { label: '备注', value: '', placeholder: '请输入', type: 'textarea', width: '100%' },
  137. };
  138. }
  139. return formData;
  140. },
  141. //表单单项验证
  142. validateField(fieldName) {
  143. this.$refs.form.validateField(fieldName);
  144. },
  145. //初始化表单数据
  146. initFormData() {
  147. this.newCompanyData = deepClone(defaultNewCompanyData);
  148. this.$refs.formGroup.activeStep = 0;
  149. },
  150. /**
  151. * 获取记录详情
  152. * 填充表单数据对象
  153. * */
  154. getDetail(data) {
  155. this.preparingData = true;
  156. this.companyId = data.companyId;
  157. detail(this.companyId).then((res) => {
  158. let formData = this.getSecondFormData(res.companyType);
  159. this.$set(this.newCompanyData.data[1],'formData', formData);
  160. for (let i=0; i<this.newCompanyData.data.length; i++) {
  161. for(let key in this.newCompanyData.data[i].formData) {
  162. this.$set(this.newCompanyData.data[i].formData[key],'value', res[key] || "");
  163. }
  164. }
  165. for (let i=0; i<this.$refs.formGroup.$refs.formGroup.length; i++) {
  166. this.$refs.formGroup.$refs.formGroup[i].editMode= this.dialogType;
  167. }
  168. this.$nextTick(() => {
  169. this.preparingData = false;
  170. })
  171. });
  172. },
  173. /**
  174. * 对话框确认按钮响应
  175. * */
  176. handleConfirm() {
  177. let data = this.$refs.formGroup.checkValue();
  178. if (!data) {
  179. return false;
  180. }
  181. if (this.dialogType === "add") {
  182. this.submitAdd(data);
  183. } else {
  184. this.submitEdit(data);
  185. }
  186. },
  187. /**
  188. * 添加记录
  189. * 校验表单数据后,add接口
  190. */
  191. async submitAdd(data) {
  192. add(data).then((res) => {
  193. //增加成功
  194. this.$refs.detailDialog.hide();
  195. this.$message.success('新增成功!')
  196. this.refresh();
  197. });
  198. },
  199. submitEdit(data) {
  200. console.log('u edi:', this.companyId)
  201. edit(this.companyId, data).then(res => {
  202. this.$refs.detailDialog.hide();
  203. this.$message.success('编辑成功!')
  204. this.refresh();
  205. });
  206. },
  207. onSubmit(data) {
  208. if (this.dialogType === 'add') {
  209. this.submitAdd(data);
  210. } else {
  211. this.submitEdit(data);
  212. }
  213. },
  214. refresh() {
  215. this.$emit('refresh', true);
  216. },
  217. itemChange(){
  218. }
  219. },
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .steps-dialog {
  224. ::v-deep .el-dialog__footer {
  225. padding-top: 0;
  226. padding-bottom: 0;
  227. }
  228. }
  229. </style>