You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

344 lines
8.8 KiB

1 day ago
  1. <template>
  2. <div class="exp-project-detail">
  3. <!-- 顶部操作按钮 -->
  4. <div class="toolbar">
  5. <el-button
  6. v-if="!editing && (status==='草稿' || status==='已驳回')"
  7. @click="handleEdit"
  8. type="primary"
  9. size="small">
  10. 编辑
  11. </el-button>
  12. <el-button
  13. v-if="editing"
  14. @click="handleSave"
  15. type="primary"
  16. size="small"
  17. :loading="saving">
  18. 保存
  19. </el-button>
  20. <el-button
  21. v-if="editing"
  22. @click="handleCancel"
  23. size="small">
  24. 取消
  25. </el-button>
  26. </div>
  27. <!-- 项目详情表单 - label在上input在下 -->
  28. <el-form
  29. :model="formData"
  30. ref="detailForm"
  31. label-position="top"
  32. v-loading="loading">
  33. <el-row :gutter="20">
  34. <!-- 左侧列 -->
  35. <el-col :span="10">
  36. <el-form-item label="试验名称(Name of the experiment)">
  37. <el-input
  38. v-model="formData.title"
  39. :readonly="!editing"
  40. placeholder="请输入试验名称">
  41. </el-input>
  42. </el-form-item>
  43. <el-form-item label="试验目的(Purpose of the experiment)">
  44. <el-input
  45. v-model="formData.purpose"
  46. :readonly="!editing"
  47. placeholder="请输入试验目的">
  48. </el-input>
  49. </el-form-item>
  50. <el-form-item label="验证方法及判断标准(Experiment Justification)">
  51. <el-input
  52. v-model="formData.justification"
  53. :readonly="!editing"
  54. placeholder="请输入验证方法及判断标准">
  55. </el-input>
  56. </el-form-item>
  57. <el-form-item label="试验产品型号(Products'type)">
  58. <el-input
  59. v-model="formData.productType"
  60. :readonly="!editing"
  61. placeholder="请输入试验产品型号">
  62. </el-input>
  63. </el-form-item>
  64. <el-form-item label="期望完成日期(Desired finish date)">
  65. <el-date-picker
  66. v-model="formData.expectedFinishDate"
  67. :disabled="!editing"
  68. type="date"
  69. format="yyyy/MM/dd"
  70. value-format="yyyy-MM-dd"
  71. placeholder="选择日期"
  72. style="width: 100%">
  73. </el-date-picker>
  74. </el-form-item>
  75. </el-col>
  76. <!-- 右侧大文本框 -->
  77. <el-col :span="14">
  78. <el-form-item label="试验申请数量(Quantity requirement)">
  79. <el-input
  80. v-model="formData.quantityReq"
  81. type="textarea"
  82. :readonly="!editing"
  83. :rows="2"
  84. placeholder="请输入试验申请数量">
  85. </el-input>
  86. </el-form-item>
  87. <el-form-item style="margin-top: 35px" label="工艺、取样、测试要求(PartIII Process,Sampling,and Test Requirement)">
  88. <el-input
  89. v-model="formData.processRequirement"
  90. type="textarea"
  91. :readonly="!editing"
  92. :rows="9"
  93. placeholder="请输入工艺、取样、测试要求">
  94. </el-input>
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. <!-- 底部试验负责人信息 -->
  99. <el-row :gutter="20">
  100. <el-col :span="10">
  101. <el-form-item label="试验负责人(Project leader)">
  102. <el-input
  103. v-model="formData.projectLeader"
  104. :readonly="!editing"
  105. placeholder="请输入试验负责人">
  106. </el-input>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="14">
  110. <el-form-item label="联系方式(Contact method)">
  111. <el-input
  112. v-model="formData.contactMethod"
  113. :readonly="!editing"
  114. placeholder="请输入联系方式">
  115. </el-input>
  116. </el-form-item>
  117. </el-col>
  118. </el-row>
  119. </el-form>
  120. </div>
  121. </template>
  122. <script>
  123. import { getExpApplyDetail, saveExpApply } from '@/api/erf/erf'
  124. export default {
  125. name: 'ExpProjectDetail',
  126. props: {
  127. applyNo: {
  128. type: String,
  129. required: true
  130. },
  131. status: {
  132. type: String,
  133. required: true
  134. },
  135. height: {
  136. type: String,
  137. default: '35vh'
  138. }
  139. },
  140. data() {
  141. return {
  142. formData: {
  143. applyNo: '',
  144. buNo: '',
  145. experimentType: '',
  146. projectNo: '',
  147. title: '',
  148. purpose: '',
  149. justification: '',
  150. productType: '',
  151. quantityReq: '',
  152. expectedFinishDate: '',
  153. projectLeader: '',
  154. contactMethod: '',
  155. processRequirement: '',
  156. status: '',
  157. creatorUserId: '',
  158. creatorName: '',
  159. createTime: '',
  160. updateTime: '',
  161. plannerUserId: '',
  162. plannerName: '',
  163. workOrderNo: '',
  164. scheduledDate: ''
  165. },
  166. originalData: {}, // 保存原始数据,用于取消时恢复
  167. loading: false,
  168. editing: false,
  169. saving: false
  170. }
  171. },
  172. watch: {
  173. applyNo: {
  174. immediate: true,
  175. handler(val) {
  176. if (val) {
  177. this.editing = false
  178. this.loadDetail()
  179. }
  180. }
  181. }
  182. },
  183. methods: {
  184. /**
  185. * 加载项目详情
  186. */
  187. loadDetail() {
  188. this.loading = true
  189. getExpApplyDetail({ applyNo: this.applyNo }).then(({data}) => {
  190. this.loading = false
  191. if (data && data.code === 0) {
  192. this.formData = { ...this.formData, ...data.data }
  193. this.originalData = JSON.parse(JSON.stringify(this.formData))
  194. } else {
  195. this.$message.error(data.msg || '加载详情失败')
  196. }
  197. }).catch(error => {
  198. this.loading = false
  199. this.$message.error('加载详情异常')
  200. })
  201. },
  202. /**
  203. * 进入编辑模式
  204. */
  205. handleEdit() {
  206. this.editing = true
  207. this.originalData = JSON.parse(JSON.stringify(this.formData))
  208. },
  209. /**
  210. * 保存修改
  211. */
  212. handleSave() {
  213. // 数据验证
  214. if (!this.formData.title) {
  215. this.$message.warning('请输入试验名称')
  216. return
  217. }
  218. if (!this.formData.expectedFinishDate) {
  219. this.$message.warning('请选择期望完成日期')
  220. return
  221. }
  222. this.saving = true
  223. // 准备保存数据
  224. const saveData = {
  225. applyNo: this.formData.applyNo,
  226. buNo: this.formData.buNo,
  227. experimentType: this.formData.experimentType,
  228. projectNo: this.formData.projectNo,
  229. title: this.formData.title,
  230. purpose: this.formData.purpose,
  231. justification: this.formData.justification,
  232. productType: this.formData.productType,
  233. quantityReq: this.formData.quantityReq,
  234. expectedFinishDate: this.formData.expectedFinishDate,
  235. projectLeader: this.formData.projectLeader,
  236. contactMethod: this.formData.contactMethod,
  237. processRequirement: this.formData.processRequirement
  238. }
  239. saveExpApply(saveData).then(({data}) => {
  240. this.saving = false
  241. if (data && data.code === 0) {
  242. this.$message.success('保存成功')
  243. this.editing = false
  244. this.loadDetail()
  245. // 通知父组件刷新列表
  246. this.$emit('refresh')
  247. } else {
  248. this.$message.error(data.msg || '保存失败')
  249. }
  250. }).catch(error => {
  251. this.saving = false
  252. this.$message.error('保存异常')
  253. })
  254. },
  255. /**
  256. * 取消编辑
  257. */
  258. handleCancel() {
  259. this.$confirm('取消编辑将放弃所有修改,确定取消?', '操作提示', {
  260. confirmButtonText: '确定',
  261. cancelButtonText: '取消',
  262. type: 'warning'
  263. }).then(() => {
  264. this.formData = JSON.parse(JSON.stringify(this.originalData))
  265. this.editing = false
  266. }).catch(() => {
  267. // 用户点击了取消
  268. })
  269. }
  270. }
  271. }
  272. </script>
  273. <style scoped>
  274. .exp-project-detail {
  275. height: 100%;
  276. overflow-y: auto;
  277. overflow-x: hidden;
  278. background-color: #fff;
  279. }
  280. .toolbar {
  281. margin-bottom: 5px;
  282. padding-bottom: 5px;
  283. border-bottom: 1px solid #EBEEF5;
  284. text-align: left;
  285. }
  286. .el-form-item {
  287. margin-bottom: 15px;
  288. }
  289. /* 只读状态的input样式 */
  290. .el-input >>> input[readonly] {
  291. background-color: #F5F7FA;
  292. border-color: #DCDFE6;
  293. color: #606266;
  294. cursor: default;
  295. }
  296. .el-input >>> textarea[readonly] {
  297. background-color: #F5F7FA;
  298. border-color: #DCDFE6;
  299. color: #606266;
  300. cursor: default;
  301. }
  302. /* 禁用状态的日期选择器样式 */
  303. .el-date-editor.is-disabled >>> .el-input__inner {
  304. background-color: #F5F7FA;
  305. border-color: #DCDFE6;
  306. color: #606266;
  307. cursor: default;
  308. }
  309. /* 调整label样式 */
  310. .el-form-item >>> .el-form-item__label {
  311. font-size: 13px;
  312. color: #606266;
  313. font-weight: normal;
  314. padding-bottom: 5px;
  315. }
  316. </style>