change-form.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="doc-page">
  3. <h3 class="page-title" style="margin: 24px 0 16px;">项目变更申请表</h3>
  4. <table>
  5. <tbody>
  6. <tr>
  7. <td class="doc-label">研发项目名称</td>
  8. <td class="doc-input">
  9. <project-select v-model="currProjectId" @change="handleProjectChange" :disabled="disabled"></project-select>
  10. </td>
  11. <td class="doc-label">研发项目编号</td>
  12. <td class="doc-input">{{ selProject.xmbh }}</td>
  13. </tr>
  14. <tr>
  15. <td class="doc-label">项目负责人</td>
  16. <td class="doc-input">{{ selProject.xmfzrxm }} </td>
  17. <td class="doc-label">项目申请单位</td>
  18. <td class="doc-input">{{ selProject.xmsqdw }}</td>
  19. </tr>
  20. <tr>
  21. <td class="doc-label">变更类型</td>
  22. <td class="doc-input" colspan="3">
  23. <avue-select
  24. v-model="formData.zdmc"
  25. placeholder="请选择"
  26. :dic="changeTypeList"
  27. style="width: 100%"
  28. :disabled="disabled"
  29. ></avue-select>
  30. </td>
  31. </tr>
  32. <tr>
  33. <td class="doc-label">变更前</td>
  34. <td class="doc-input">
  35. <span v-if="!disabled">{{ selProject[formData.zdmc == 'xmfzr' ? 'xmfzrxm' : formData.zdmc] }}</span>
  36. <span>{{ formData.bgqdz }}</span>
  37. </td>
  38. <td class="doc-label">变更后</td>
  39. <td class="doc-input">
  40. <el-input v-if="formData.zdmc === 'xmmc'" placeholder="请输入项目名称" v-model="formData.bghdz" :disabled="disabled" />
  41. <el-date-picker
  42. v-if="'xmkssj,xmjssj'.indexOf(formData.zdmc) > -1"
  43. v-model="formData.bghdz"
  44. format="yyyy年MM月dd日"
  45. value-format="yyyy-MM-dd"
  46. placeholder="请选择日期"
  47. style="width: 100%"
  48. :disabled="disabled"
  49. ></el-date-picker>
  50. <avue-select
  51. v-if="formData.zdmc === 'xmfzr'"
  52. v-model="formData.bghdz"
  53. placeholder="请选择"
  54. :dic="fzrList"
  55. style="width: 100%"
  56. :disabled="disabled"
  57. ></avue-select>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="doc-label">变更原因说明</td>
  62. <td class="doc-input" colspan="3">
  63. <el-input v-model="formData.bgyy" type="textarea" :rows="3" :disabled="disabled" />
  64. </td>
  65. </tr>
  66. <tr>
  67. <td class="doc-label">变更生效时间</td>
  68. <td class="doc-input" colspan="3">
  69. <el-date-picker
  70. v-model="formData.bgsxsj"
  71. format="yyyy年MM月dd日"
  72. value-format="yyyy-MM-dd"
  73. placeholder="请选择日期"
  74. style="width: 100%"
  75. :disabled="disabled"
  76. ></el-date-picker>
  77. </td>
  78. </tr>
  79. <tr>
  80. <td class="doc-label">附件上传</td>
  81. <td class="doc-input" colspan="3" style="text-align: left;">
  82. <avue-upload
  83. v-if="!disabled"
  84. action="/api/kd-resource/oss/endpoint/put-file"
  85. dataType="object"
  86. :props-http="{
  87. url: 'link',
  88. name: 'originalName',
  89. res: 'data',
  90. }"
  91. type="upload"
  92. v-model="formData.attachment"
  93. style="margin: 14px 0 14px 12px;"
  94. :disabled="disabled"
  95. ></avue-upload>
  96. <div v-else>
  97. <div v-for="(item, index) of formData.attachment" :key="index" style="line-height: 26px; padding: 6px;">
  98. <el-link @click="handleDownFile(item)">{{ item.label }}</el-link>
  99. </div>
  100. </div>
  101. </td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. <div v-if="!disabled" class="btn-wrap" style="text-align: center; margin-top: 30px;">
  106. <el-button style="width: 160px;" @click="handleResetBtn">重置</el-button>
  107. <el-button type="primary" style="width: 160px;" @click="handleSaveBtn">保存</el-button>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. import { getDictionary } from "@/api/system/dictbiz";
  113. import { getList as getTechnicanRosterList } from "@/api/basicResource/technicianRoster";
  114. import { save } from "@/api/projectManage/change";
  115. import moment from "moment";
  116. import projectSelect from "@/components/project-select";
  117. export default {
  118. props: {
  119. projectId: [String, Number],
  120. data: Object,
  121. disabled: {
  122. type: Boolean,
  123. type: false
  124. }
  125. },
  126. components: {
  127. projectSelect
  128. },
  129. data() {
  130. return {
  131. currProjectId: '',
  132. formData: {
  133. attachment: []
  134. },
  135. changeTypeList: [],
  136. loading: false,
  137. selProject: {},
  138. fzrList: [],
  139. };
  140. },
  141. watch: {
  142. "formData.zdmc"(newVal) {
  143. if (newVal == 'xmfzr') {
  144. this.getTechnicanRosterListFunc(moment(this.selProject.xmkssj).format('yyyyMM'));
  145. }
  146. }
  147. },
  148. mounted() {
  149. this.getDictList("xm_biangeng_field", "changeTypeList");
  150. this.currProjectId = this.projectId;
  151. this.formData = {
  152. ...this.data,
  153. };
  154. console.log(this.formData.attachment)
  155. },
  156. methods: {
  157. /**
  158. * 获取人员花名册
  159. */
  160. getTechnicanRosterListFunc(yearAndMonth) {
  161. getTechnicanRosterList(1, 99999, { yearAndMonth }).then(res => {
  162. if (res.data.success) {
  163. this.fzrList = res.data.data.records.map(item => {
  164. return { label: item.name, value: item.id };
  165. });
  166. }
  167. });
  168. },
  169. getDictList(code, toListKey) {
  170. getDictionary({ code }).then((res) => {
  171. this[toListKey] = res.data.data.map((item) => {
  172. return { label: item.dictValue, value: item.dictKey };
  173. });
  174. });
  175. },
  176. handleProjectChange(data) {
  177. this.selProject = data;
  178. },
  179. validForm() {
  180. let errorText = '';
  181. if (!this.currProjectId) {
  182. errorText = '请选择变更的项目';
  183. } else if (!this.formData.zdmc) {
  184. errorText = '请选择变更类型';
  185. } else if (!this.formData.bgyy) {
  186. errorText = '请输入变更原因';
  187. } else if (!this.formData.bgsxsj) {
  188. errorText = '请选择变更生效时间';
  189. } else if (!this.formData.bghdz) {
  190. errorText = '请输入变更后的值';
  191. }
  192. return errorText;
  193. },
  194. handleResetBtn() {
  195. this.formData = {};
  196. },
  197. handleSaveBtn() {
  198. let errorText = this.validForm();
  199. if (errorText) {
  200. this.$message.error(errorText+'!');
  201. return;
  202. }
  203. const params = {
  204. ...this.formData,
  205. bgqdz: this.selProject[this.formData.zdmc],
  206. attachment: JSON.stringify(this.formData.attachment),
  207. xmId: this.currProjectId
  208. };
  209. this.saveData(params);
  210. },
  211. saveData(params) {
  212. save(params).then(({ data }) => {
  213. if (data.code == 200) {
  214. this.$message.success("保存成功!");
  215. this.$emit("success");
  216. }
  217. });
  218. },
  219. handleDownFile(file) {
  220. window.open(file.value);
  221. }
  222. },
  223. };
  224. </script>
  225. <style lang="scss" scoped>
  226. .page-title {
  227. text-align: center;
  228. font-size: 24px;
  229. }
  230. .doc-page {
  231. width: 800px;
  232. margin: 30px auto;
  233. }
  234. table {
  235. width: 100%;
  236. border: 1px solid #333;
  237. }
  238. .doc-label {
  239. text-align: center;
  240. padding: 6px;
  241. color: #777;
  242. font-size: 14px;
  243. width: 15%;
  244. }
  245. .doc-input {
  246. text-align: center;
  247. color: #333;
  248. width: 35%;
  249. }
  250. .el-input__inner {
  251. border: none;
  252. }
  253. tr td {
  254. border: 1px solid #333;
  255. }
  256. </style>