implement.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <basic-container>
  3. <div style="margin-top: 6px;">
  4. <el-form :inline="true">
  5. <el-form-item label="研发项目名称">
  6. <project-select v-model="params.xmId" @change="handleProjectChange"></project-select>
  7. </el-form-item>
  8. <el-form-item label="研发项目编号">
  9. {{ selProject.xmbh }}
  10. </el-form-item>
  11. </el-form>
  12. </div>
  13. <avue-crud
  14. ref="crud"
  15. v-bind="bindVal"
  16. v-on="onEvent"
  17. v-model="form"
  18. :page.sync="page"
  19. :before-open="handleBeforeOpen"
  20. :permission="permissionList"
  21. @row-dblclick="handleRowDbClick"
  22. >
  23. <template slot="menuLeft">
  24. <el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd">
  25. 新增
  26. </el-button>
  27. <el-button
  28. type="warning"
  29. size="small"
  30. plain
  31. icon="el-icon-download"
  32. @click="handleExport"
  33. >
  34. 导出
  35. </el-button>
  36. <print-table-btn @click="printTable" />
  37. </template>
  38. <template slot-scope="{row, index}" slot="menu">
  39. <el-button type="text" icon="el-icon-edit" @click="rowEdit(row)" style="margin-right: 12px;">编辑</el-button>
  40. <el-button type="text" icon="el-icon-delete" style="margin-left: 0;" @click="rowDel(row, index)">删除</el-button>
  41. </template>
  42. </avue-crud>
  43. <WideTablePrinter
  44. ref="printWideTable"
  45. :columns="wideTableColumns"
  46. :data="data"
  47. :print-title="printTitle"
  48. :rows-per-page="30"
  49. :default-landscape="true"
  50. />
  51. <el-drawer
  52. v-if="drawerVisible"
  53. :title="drawerTitle"
  54. :visible.sync="drawerVisible"
  55. modal-append-to-body
  56. append-to-body
  57. size="960px"
  58. >
  59. <implement-form
  60. :projectId="params.xmId"
  61. :data="implementFormData"
  62. :disabled="isFormReadonly"
  63. @success="handleImplementSucc"
  64. >
  65. </implement-form>
  66. </el-drawer>
  67. </basic-container>
  68. </template>
  69. <script>
  70. import {exportBloByPost} from "@/api/common";
  71. import {getToken} from "@/util/auth";
  72. import projectSelect from "@/components/project-select";
  73. import {downloadXls} from "@/util/util";
  74. import implementForm from "./components/implement-form.vue";
  75. export default window.$crudCommon({
  76. props: {
  77. projectId: [String, Number]
  78. },
  79. components: {
  80. implementForm,
  81. projectSelect
  82. },
  83. data() {
  84. return {
  85. params: {
  86. xmId: ''
  87. },
  88. selProject: {},
  89. drawerTitle: "",
  90. drawerVisible: false,
  91. wideTableColumns: [],
  92. printTitle: "",
  93. implementFormData: {},
  94. isFormReadonly: false,
  95. };
  96. },
  97. watch: {
  98. "params.xmId"() {
  99. this.getList();
  100. }
  101. },
  102. created() {
  103. this.params.xmId = this.projectId;
  104. },
  105. methods: {
  106. handleImplementSucc() {
  107. this.drawerVisible = false;
  108. this.loadData();
  109. },
  110. loadData() {
  111. if (!this.params.xmId) {
  112. return;
  113. }
  114. this.loading = true;
  115. this.api[this.option.list || 'getList'](this.params.xmId).then(({ data }) => {
  116. this.data = data.data.map(item => {
  117. item.xmmc = item.xmEntity ? item.xmEntity.xmmc : '';
  118. item.xmbh = item.xmEntity ? item.xmEntity.xmbh : '';
  119. item.xmsqdw = item.xmEntity ? item.xmEntity.xmsqdw : '';
  120. item.xmfzrxm = item.xmEntity ? item.xmEntity.xmfzrxm : '';
  121. return item;
  122. });
  123. this.loading = false;
  124. });
  125. },
  126. handleProjectChange(data) {
  127. this.selProject = data;
  128. },
  129. handleExport() {
  130. exportBloByPost(`/api/kd-scientific/xm-bgrz/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  131. downloadXls(res.data, `${this.selProject.xmmc}阶段性报告列表.xlsx`);
  132. });
  133. },
  134. /**
  135. * 打印表格
  136. * @param isLandscape 是否横向打印
  137. */
  138. printTable(isLandscape) {
  139. this.wideTableColumns = this.$refs.crud.columnOption;
  140. this.printTitle = `${this.selProject.xmmc}阶段性报告列表`;
  141. this.$nextTick(() => {
  142. this.$refs.printWideTable.printTable(isLandscape);
  143. })
  144. },
  145. handleAdd() {
  146. this.drawerVisible = true;
  147. this.isFormReadonly = false;
  148. this.drawerTitle = "新增阶段性报告";
  149. this.implementFormData = {};
  150. },
  151. rowEdit(data) {
  152. this.drawerVisible = true;
  153. this.isFormReadonly = false;
  154. this.drawerTitle = "编辑阶段性报告";
  155. this.implementFormData = {
  156. ...data,
  157. attachment: data.attachment ? JSON.parse(data.attachment) : []
  158. };
  159. },
  160. handleRowDbClick(data) {
  161. this.drawerVisible = true;
  162. this.isFormReadonly = true;
  163. this.drawerTitle = "阶段性报告详情";
  164. this.implementFormData = {
  165. ...data,
  166. attachment: data.attachment ? JSON.parse(data.attachment) : []
  167. };
  168. },
  169. handleChangeSucc() {
  170. this.drawerVisible = false;
  171. this.getList();
  172. }
  173. },
  174. }, {
  175. // 模块路径
  176. name: 'projectManage/implement',
  177. });
  178. </script>