declarationDialog.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :visible.sync="visibleDialog"
  5. :title="title"
  6. :close-on-click-modal="false"
  7. width="85%"
  8. append-to-body
  9. @close="handleClose"
  10. :maxable="true"
  11. >
  12. <el-form ref="form" :model="addForm" label-width="120px">
  13. <el-row :gutter="24">
  14. <el-col :span="8">
  15. <el-form-item
  16. label="实际起始时间"
  17. prop="time"
  18. :rules="{
  19. required: true,
  20. message: '实际起始时间',
  21. trigger: 'change'
  22. }"
  23. >
  24. <el-date-picker
  25. style="width: 100%"
  26. v-model="addForm.time"
  27. type="datetimerange"
  28. value-format="yyyy-MM-dd HH:mm:ss"
  29. range-separator="至"
  30. start-placeholder="实际开始日期"
  31. end-placeholder="实际结束日期"
  32. :disabled="type == 'view'"
  33. @change="getTime"
  34. >
  35. </el-date-picker>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-form-item label="实际售后时长" prop="inFactDuration">
  40. <el-input v-model="addForm.inFactDuration" :disabled="true">
  41. <template slot="append">min</template>
  42. </el-input>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="8">
  46. <el-form-item label="附件" prop="attachments">
  47. <fileMain
  48. v-model="addForm.attachments"
  49. :type="type == 'view' ? 'view' : 'add'"
  50. ></fileMain>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="故障现象" prop="faultPhenomenon">
  55. <el-input
  56. type="textarea"
  57. placeholder="请输入内容"
  58. v-model="addForm.faultPhenomenon"
  59. :disabled="type == 'view'"
  60. >
  61. </el-input>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="8">
  65. <el-form-item label="故障原因" prop="faultReason">
  66. <el-input
  67. type="textarea"
  68. placeholder="请输入内容"
  69. v-model="addForm.faultReason"
  70. :disabled="type == 'view'"
  71. >
  72. </el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="8">
  76. <el-form-item label="维修过程" prop="maintenanceProcess">
  77. <el-input
  78. type="textarea"
  79. placeholder="请输入内容"
  80. v-model="addForm.maintenanceProcess"
  81. :disabled="type == 'view'"
  82. >
  83. </el-input>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="24">
  87. <info ref="infoRef" type="view" :isPurchaseNeed="false"></info>
  88. </el-col>
  89. <el-col :span="24">
  90. <header-title title="方案" style="margin-top: 10px"></header-title>
  91. <spareParts
  92. ref="sparePartsRef"
  93. :type="type == 'edit' ? 'edit' : 'view'"
  94. ></spareParts>
  95. </el-col>
  96. <el-col :span="8" v-if="type=='view'">
  97. <el-form-item label="报工时间" prop="acceptTime">
  98. <el-input
  99. v-model="addForm.acceptTime"
  100. :disabled="true"
  101. >
  102. </el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="8" v-if="type=='view'">
  106. <el-form-item label="报工人" prop="executeUserName">
  107. <el-input
  108. v-model="addForm.executeUserName"
  109. :disabled="true"
  110. >
  111. </el-input>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="8" v-if="type=='view'">
  115. <el-form-item label="验收人" prop="accepterUserName">
  116. <el-input
  117. v-model="addForm.accepterUserName"
  118. :disabled="true"
  119. >
  120. </el-input>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="8" v-if="type=='view'">
  124. <el-form-item label="验收时间" prop="accepterTime">
  125. <el-input
  126. v-model="addForm.accepterTime"
  127. :disabled="true"
  128. >
  129. </el-input>
  130. </el-form-item>
  131. </el-col>
  132. <el-col :span="8" v-if="type=='view'">
  133. <el-form-item label="验收意见" prop="accepterRemark">
  134. <el-input
  135. v-model="addForm.accepterRemark"
  136. :disabled="true"
  137. type="textarea"
  138. >
  139. </el-input>
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. </el-form>
  144. <div slot="footer" class="footer">
  145. <el-button type="primary" @click="submitAdd" v-if="type == 'report'"
  146. >提交</el-button
  147. >
  148. <el-button type="primary" @click="submitAdd" v-if="type == 'edit'"
  149. >保存</el-button
  150. >
  151. <el-button @click="handleClose">取消</el-button>
  152. </div>
  153. </ele-modal>
  154. </template>
  155. <script>
  156. import fileMain from '@/components/addDoc/index.vue';
  157. import {
  158. reportWorkingSalesWorkOrder,
  159. updateScheme,
  160. getSalesWorkOrderById
  161. } from '@/api/salesServiceManagement/index';
  162. import spareParts from '@/views/salesServiceManagement/components/sparePartsList.vue';
  163. import info from '@/views/salesServiceManagement/components/info.vue';
  164. export default {
  165. props: {},
  166. components: {
  167. fileMain,
  168. spareParts,
  169. info
  170. },
  171. watch: {},
  172. computed: {},
  173. data() {
  174. return {
  175. title: '',
  176. visibleDialog: false,
  177. addForm: {
  178. id: '',
  179. time: [],
  180. attachments: [],
  181. reason: ''
  182. },
  183. row: {},
  184. type: ''
  185. };
  186. },
  187. created() {},
  188. methods: {
  189. open(row, type) {
  190. this.visibleDialog = true;
  191. this.type = type;
  192. this.title = type == 'edit' ? '修改' : type == 'view' ? '详情' : '报工';
  193. this.getDetail(row);
  194. },
  195. async getDetail(row) {
  196. const res = await getSalesWorkOrderById(row.id);
  197. this.addForm = res;
  198. if (this.addForm.acceptTime) {
  199. this.$set(this.addForm, 'time', [
  200. this.addForm.acceptTime,
  201. this.addForm.finishTime
  202. ]);
  203. }
  204. this.$nextTick(() => {
  205. this.$refs.infoRef.init(res.afterSalesDemandVO);
  206. this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
  207. });
  208. },
  209. async submitAdd() {
  210. this.$refs.form.validate(async (valid) => {
  211. if (valid) {
  212. let data = {
  213. acceptTime: this.addForm.time?.[0],
  214. finishTime: this.addForm.time?.[1],
  215. attachments: this.addForm.attachments,
  216. maintenanceProcess: this.addForm.maintenanceProcess,
  217. faultPhenomenon: this.addForm.faultPhenomenon,
  218. faultReason: this.addForm.faultReason,
  219. inFactDuration: this.addForm.inFactDuration,
  220. id: this.addForm.id,
  221. costListVOS: this.$refs.sparePartsRef.getTableValue()
  222. };
  223. let api =
  224. this.type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
  225. await api(data).then((res) => {
  226. if (!res) return;
  227. this.$message.success('操作成功');
  228. this.visibleDialog = false;
  229. this.$emit('reload');
  230. });
  231. } else {
  232. return false;
  233. }
  234. });
  235. },
  236. getTime() {
  237. if (this.addForm.time?.length) {
  238. this.$set(
  239. this.addForm,
  240. 'inFactDuration',
  241. parseInt(
  242. (new Date(this.addForm.time[1]).getTime() -
  243. new Date(this.addForm.time[0]).getTime()) /
  244. 60000
  245. )
  246. );
  247. }
  248. },
  249. handleClose() {
  250. this.visibleDialog = false;
  251. }
  252. }
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. .dialog_top {
  257. margin-bottom: 10px;
  258. display: flex;
  259. align-items: center;
  260. span {
  261. margin-left: 50px;
  262. }
  263. .name {
  264. font-weight: 800;
  265. color: #40a9ff;
  266. }
  267. }
  268. ::v-deep .el-row {
  269. display: flex;
  270. flex-wrap: wrap;
  271. }
  272. .btns {
  273. text-align: right;
  274. // margin: 10px 0;
  275. }
  276. .main_container {
  277. width: 100%;
  278. display: flex;
  279. justify-content: space-between;
  280. }
  281. </style>