index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="leftTop"> <span>|</span> <span>调研调查</span> </el-col>
  6. <el-col :span="24" class="info">
  7. <span v-if="display == 'list'">
  8. <el-col :span="24" class="list">
  9. <el-tabs v-model="active" type="card">
  10. <el-tab-pane label="已参加" name="first">
  11. <data-table
  12. v-if="tabs === 'first'"
  13. :fields="fields"
  14. :opera="opera"
  15. :data="twoList"
  16. :total="twoTotal"
  17. @query="data => search(data, true)"
  18. @edit="toGetList"
  19. ></data-table>
  20. <el-row v-else>
  21. <el-col :span="24" style="text-align:right; padding:15px">
  22. <el-button type="primary" size="mini" @click="toAdd" style="margin-right:20px">再次填报</el-button>
  23. <el-button type="primary" size="mini" @click="tabs = 'first'">返回列表</el-button>
  24. </el-col>
  25. <el-col :span="24">
  26. <data-table
  27. :fields="solicFields"
  28. :opera="solicOpera"
  29. :data="solicList"
  30. :total="solicTotal"
  31. @query="getSolicList"
  32. @edit="toSolicEdit"
  33. @view="toSolicView"
  34. ></data-table>
  35. </el-col>
  36. </el-row>
  37. </el-tab-pane>
  38. <el-tab-pane label="未参加" name="second">
  39. <data-table :fields="fields" :opera="opera" :data="oneList" :total="oneTotal" @query="data => search(data, false)" @add="toAdd"></data-table>
  40. </el-tab-pane>
  41. </el-tabs>
  42. </el-col>
  43. </span>
  44. <span v-else-if="display == 'update'">
  45. <el-col :span="24" class="update">
  46. <el-col :span="24" class="btn">
  47. <el-button type="primary" size="mini" @click="back">返回列表</el-button>
  48. </el-col>
  49. <el-col :span="24" class="updateForm">
  50. <el-tabs v-model="updateActive" type="card">
  51. <el-tab-pane label="信息填报" name="first">
  52. <projectForm :form="form" @resetBtn="back" @onSubmit="onSubmit"></projectForm>
  53. </el-tab-pane>
  54. </el-tabs>
  55. </el-col>
  56. </el-col>
  57. </span>
  58. <span v-else-if="display == 'viewInfo'">
  59. <el-col :span="24" class="viewInfo">
  60. <el-col :span="24" class="btn">
  61. <el-button type="primary" size="mini" @click="back">返回列表</el-button>
  62. </el-col>
  63. <el-col :span="24" class="viewInfoMess">
  64. <el-col :span="24" class="title">
  65. 2022年度吉林省科技发展计划高新技术领域项目建议书
  66. </el-col>
  67. <el-col :span="24">
  68. <projectInfo :info="form"></projectInfo>
  69. </el-col>
  70. </el-col>
  71. </el-col>
  72. </span>
  73. <span v-else-if="display == 'detail'">
  74. <el-col :span="24" class="detail">
  75. <el-col :span="24" class="btn">
  76. <el-button type="primary" size="mini" @click="back">返回列表</el-button>
  77. </el-col>
  78. <el-col :span="24" class="form">
  79. <el-tabs v-model="formActive" type="card">
  80. <el-tab-pane label="通知正文" name="first">
  81. <questionInfo :info="info"></questionInfo>
  82. </el-tab-pane>
  83. <el-tab-pane label="信息填报" name="second">
  84. <projectForm :form="form" @resetBtn="back" @onSubmit="onSubmit"></projectForm>
  85. </el-tab-pane>
  86. </el-tabs>
  87. </el-col>
  88. </el-col>
  89. </span>
  90. </el-col>
  91. </el-col>
  92. </el-row>
  93. </div>
  94. </template>
  95. <script>
  96. const _ = require('lodash');
  97. import dataTable from '@/components/data-table.vue';
  98. import questionInfo from './parts/questionInfo.vue';
  99. import projectForm from './parts/projectForm.vue';
  100. import projectInfo from './parts/projectInfo.vue';
  101. import { mapState, createNamespacedHelpers } from 'vuex';
  102. const { mapActions: question } = createNamespacedHelpers('question');
  103. const { mapActions: projectsolic } = createNamespacedHelpers('projectsolic');
  104. export default {
  105. metaInfo() {
  106. return { title: this.$route.meta.title };
  107. },
  108. name: 'index',
  109. props: {},
  110. components: {
  111. dataTable,
  112. questionInfo,
  113. projectForm,
  114. projectInfo,
  115. },
  116. data: function() {
  117. return {
  118. // 显示
  119. display: 'list',
  120. // 列表
  121. active: 'first',
  122. // 已参加列表
  123. tabs: 'first',
  124. opera: [
  125. {
  126. label: '查看项目征集信息',
  127. method: 'add',
  128. display: i => !i.exist,
  129. },
  130. {
  131. label: '查看项目征集信息',
  132. method: 'edit',
  133. display: i => i.exist,
  134. },
  135. ],
  136. fields: [
  137. { label: '信息标题', prop: 'title' },
  138. { label: '信息来源', prop: 'origin' },
  139. { label: '发布时间', prop: 'create_date' },
  140. ],
  141. // 未参加
  142. oneList: [],
  143. oneTotal: 0,
  144. // 已参加
  145. twoList: [],
  146. twoTotal: 0,
  147. solicList: [],
  148. solicTotal: 0,
  149. solicFields: [
  150. { label: '项目名称', prop: 'name' },
  151. { label: '项目负责人', prop: 'pro_user' },
  152. { label: '联系电话', prop: 'pro_phone' },
  153. { label: '状态', prop: 'status', format: i => (i === '0' ? '草稿' : '已提交') },
  154. ],
  155. solicOpera: [
  156. {
  157. label: '修改',
  158. method: 'edit',
  159. display: i => i.status === '0',
  160. },
  161. {
  162. label: '详情',
  163. method: 'view',
  164. display: i => i.status === '1',
  165. },
  166. ],
  167. // 添加,修改
  168. formActive: 'first',
  169. // 调研调查信息
  170. info: {},
  171. form: {},
  172. // 修改信息
  173. updateActive: 'first',
  174. // 详情
  175. };
  176. },
  177. async created() {
  178. await this.search({}, true);
  179. await this.search({}, false);
  180. },
  181. methods: {
  182. ...question({ questionQuery: 'query' }),
  183. ...projectsolic(['query', 'create', 'update', 'delete']),
  184. async search({ skip = 0, limit = 10, ...info } = {}, exist) {
  185. const res = await this.questionQuery({ skip, limit, ...info, exist, user_id: this.user.userid });
  186. if (this.$checkRes(res)) {
  187. let type = 'one';
  188. if (exist) type = 'two';
  189. this.$set(this, `${type}List`, res.data);
  190. this.$set(this, `${type}Total`, res.total);
  191. }
  192. },
  193. toAdd({ data }) {
  194. this.display = 'detail';
  195. if (data) this.$set(this, 'info', data);
  196. this.form.question_id = _.get(data, '_id', this.info._id);
  197. this.form.user_id = this.user.userid;
  198. },
  199. async toEdit({ data }) {
  200. this.display = 'detail';
  201. this.$set(this, 'info', data);
  202. },
  203. async toGetList({ data }) {
  204. this.$set(this, 'info', data);
  205. await this.getSolicList({}, data);
  206. this.tabs = 'sec';
  207. },
  208. async getSolicList({ skip = 0, limit = 10, ...info } = {}) {
  209. const res = await this.query({ question_id: this.info._id, user_id: this.user.userid, skip, limit });
  210. if (this.$checkRes(res)) {
  211. this.$set(this, 'solicList', res.data);
  212. this.$set(this, 'solicTotal', res.total);
  213. }
  214. },
  215. toSolicEdit({ data }) {
  216. this.$set(this, 'form', data);
  217. this.display = 'update';
  218. },
  219. toSolicView({ data }) {
  220. this.$set(this, 'form', data);
  221. this.display = 'viewInfo';
  222. },
  223. // 提交保存
  224. async onSubmit({ data }) {
  225. const dup = _.cloneDeep(data);
  226. let res;
  227. if (dup.id) {
  228. res = await this.update(dup);
  229. } else {
  230. res = await this.create(dup);
  231. }
  232. if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) {
  233. this.search({}, true);
  234. this.search({}, false);
  235. if (this.tabs === 'sec') this.getSolicList();
  236. this.back();
  237. }
  238. },
  239. // 返回列表
  240. back() {
  241. this.form = {};
  242. this.display = 'list';
  243. this.search();
  244. },
  245. },
  246. computed: {
  247. ...mapState(['user']),
  248. },
  249. watch: {},
  250. };
  251. </script>
  252. <style lang="less" scoped>
  253. .main {
  254. .leftTop {
  255. font-size: 18px;
  256. width: 96%;
  257. height: 41px;
  258. line-height: 35px;
  259. border-bottom: 1px solid #e5e5e5;
  260. position: relative;
  261. bottom: 1px;
  262. margin: 10px;
  263. font-weight: 600;
  264. color: #22529a;
  265. }
  266. .info {
  267. padding: 0 40px 0 10px;
  268. .detail {
  269. .btn {
  270. text-align: right;
  271. margin: 0 0 10px 0;
  272. }
  273. }
  274. .update {
  275. .btn {
  276. text-align: right;
  277. margin: 0 0 10px 0;
  278. }
  279. }
  280. .viewInfo {
  281. .btn {
  282. text-align: right;
  283. margin: 0 0 10px 0;
  284. }
  285. .viewInfoMess {
  286. .title {
  287. font-size: 25px;
  288. text-align: center;
  289. margin: 0 0 30px 0;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. </style>