reviewModal.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. @register="register"
  5. title="接单"
  6. @cancel="resetFields"
  7. @ok="handleSubmit"
  8. :min-height="0"
  9. >
  10. <BasicForm @register="registerForm" >
  11. <template #text="{ model, field }">
  12. {{ model[field] }}
  13. </template>
  14. </BasicForm>
  15. </BasicModal>
  16. </template>
  17. <script lang="ts">
  18. import { defineComponent, ref, onMounted, h } from 'vue';
  19. import { BasicModal, useModalInner } from '/@/components/Modal';
  20. import { useMessage } from '/@/hooks/web/useMessage';
  21. import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
  22. import { testPassOrFail } from '/@/api/spares';
  23. import { uploadApi } from '/@/api/product/index';
  24. import { useI18n } from '/@/hooks/web/useI18n';
  25. const { t } = useI18n();
  26. export default defineComponent({
  27. components: { BasicModal, BasicForm },
  28. props: {
  29. userData: { type: Object },
  30. },
  31. emits: ['update'],
  32. setup(_, { emit }) {
  33. const modelRef = ref({});
  34. const schemas: FormSchema[] = [
  35. {
  36. field: 'repairId',
  37. component: 'Input',
  38. slot: 'text',
  39. label: '维修单号',
  40. componentProps: {
  41. maxLength: 50,
  42. }, colProps: {
  43. span: 18,
  44. },
  45. },
  46. {
  47. field: 'deviceType',
  48. component: 'Input',
  49. slot: 'text',
  50. label: '设备信息',
  51. },{
  52. field: 'resultStatus',
  53. component: 'RadioGroup',
  54. required: true,
  55. label: '测试结果',
  56. defaultValue:0,
  57. componentProps: {
  58. options:[
  59. { label: '通过', value: 0 },
  60. { label: '不通过', value: 1 },
  61. ],
  62. },
  63. },
  64. {
  65. field: 'resultInfo',
  66. component: 'InputTextArea',
  67. label: '测试描述',
  68. componentProps: {
  69. maxLength: 500,
  70. rows: 3,
  71. },
  72. colProps: {
  73. span: 18,
  74. },
  75. },
  76. {
  77. field: 'resultImg',
  78. component: 'Upload',
  79. label: '相关图片',
  80. itemProps: {
  81. validateTrigger: 'blur',
  82. },
  83. componentProps: {
  84. api: uploadApi,
  85. // fileFlow:true,
  86. maxNumber: 5,
  87. maxSize: 5,
  88. accept: ['jpeg', 'jpg', 'png'],
  89. },
  90. colProps: {
  91. span: 12,
  92. },
  93. },
  94. ];
  95. const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
  96. labelWidth: 100,
  97. schemas: schemas,
  98. showActionButtonGroup: false,
  99. actionColOptions: {
  100. span: 24,
  101. },
  102. });
  103. const { createMessage, createConfirm } = useMessage();
  104. onMounted(() => {});
  105. let addListFunc = () => {};
  106. const [register, { closeModal }] = useModalInner((data) => {
  107. // console.log(data);
  108. data && onDataReceive(data);
  109. });
  110. function onDataReceive(data) {
  111. modelRef.value = data;
  112. resetFields();
  113. setFieldsValue({
  114. ...data,
  115. deviceType:t(`routes.scene.tableType.${data.cameraType || 0}`) +' '+ data.cameraSnCode
  116. });
  117. }
  118. const handleSubmit = async () => {
  119. createConfirm({
  120. iconType: 'warning',
  121. title: () => h('span', '温馨提示'),
  122. content: '确定要提交测试结果吗?',
  123. onOk: async () => {
  124. const params = await validate()
  125. const res = await testPassOrFail(params);
  126. console.log('validate',params,res)
  127. createMessage.success(t('common.optSuccess'));
  128. closeModal();
  129. emit('update');
  130. },
  131. });
  132. };
  133. return {
  134. register,
  135. model: modelRef,
  136. registerForm,
  137. handleSubmit,
  138. addListFunc,
  139. resetFields,
  140. t,
  141. };
  142. },
  143. });
  144. </script>
  145. <style lang="less" scoped>
  146. .recoverPage {
  147. .form_item {
  148. line-height: 30px;
  149. .item_lable {
  150. display: inline-block;
  151. width: 100px;
  152. text-align: right;
  153. }
  154. }
  155. }
  156. </style>