paramset.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <el-scrollbar ref="scrollDiv" :style="{height:height}">
  3. <div >
  4. <!--顶部按钮 请根据实际添加-->
  5. <div class="dynamic-form" style="padding-left: 3px;">
  6. <!--表头-->
  7. <div class="form-header">
  8. <div class="el-dialog--center" style="height:40px;vertical-align: top;padding-top:10px;font-size: 18px;font-weight: bold;" >质量监督体系指标配置</div>
  9. </div>
  10. <div style="text-align: right;padding-right: 35px;">
  11. <div style="float:right;padding-right: 10px;"><el-button type="primary" size="small" @click="exportExcel">导出上传模板</el-button></div>
  12. <el-upload style="float:right;padding-right: 10px;"
  13. class="upload"
  14. :action="uploadActionUrl"
  15. ref="upload"
  16. :on-success="mySuccess">
  17. <el-button slot="trigger" size="small" type="primary">批量上传</el-button>
  18. </el-upload>
  19. <div style="float:right;padding-right: 10px;"><el-button type="primary" size="small" @click="remove">删除</el-button></div>
  20. <div style="float:right;padding-right: 10px;"><el-button type="primary" size="small" @click="add">新增</el-button></div>
  21. </div>
  22. <el-table border="1"
  23. :data="json_data"
  24. style="width: 98%">
  25. <el-table-column
  26. prop="name0"
  27. label=""
  28. width="40">
  29. <template slot-scope="scope">
  30. <input type="checkbox" v-model="scope.row.rowChecked" :value="scope.row.id"/>
  31. </template>
  32. </el-table-column>
  33. <el-table-column
  34. prop="name0"
  35. label="编号"
  36. width="70">
  37. <template slot-scope="scope">
  38. <input type="text" v-model="scope.row.id" v-show="scope.row.iseditor" />
  39. <span v-show="!scope.row.iseditor">{{scope.row.id}}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column
  43. prop="name1"
  44. label="记录表单名称"
  45. width="180">
  46. <template slot-scope="scope">
  47. <input type="text" v-model="scope.row.formName" v-show="scope.row.iseditor" />
  48. <span v-show="!scope.row.iseditor">{{scope.row.formName}}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. prop="name0"
  53. label="程序文件"
  54. width="180">
  55. <template slot-scope="scope">
  56. <input type="text" v-model="scope.row.funcName" v-show="scope.row.iseditor" />
  57. <span v-show="!scope.row.iseditor">{{scope.row.funcName}}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. prop="name2"
  62. label="填写频率/时机"
  63. width="100">
  64. <template slot-scope="scope">
  65. <input type="text" v-model="scope.row.recRate" v-show="scope.row.iseditor" />
  66. <span v-show="!scope.row.iseditor">{{scope.row.recRate}}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column
  70. prop="name3"
  71. label="填写人"
  72. width="100">
  73. <template slot-scope="scope">
  74. <input type="text" v-model="scope.row.post" v-show="scope.row.iseditor" />
  75. <span v-show="!scope.row.iseditor">{{scope.row.post}}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. prop="name4"
  80. label="审核人/审批人"
  81. width="100">
  82. <template slot-scope="scope">
  83. <input type="text" v-model="scope.row.auditor" v-show="scope.row.iseditor" />
  84. <span v-show="!scope.row.iseditor">{{scope.row.auditor}}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="name5"
  89. label="预期目标"
  90. width="180">
  91. <template slot-scope="scope">
  92. <input type="text" v-model="scope.row.exp" v-show="scope.row.iseditor" />
  93. <span v-show="!scope.row.iseditor">{{scope.row.exp}}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. prop="name5"
  98. label="计算公式"
  99. width="180">
  100. <template slot-scope="scope">
  101. <input type="text" v-model="scope.row.checkInd" v-show="scope.row.iseditor" />
  102. <span v-show="!scope.row.iseditor">{{scope.row.checkInd}}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="操作" width="180">
  106. <template slot-scope="scope">
  107. <el-button type="warning" @click="edit(scope.row, scope)">编辑</el-button>
  108. <el-button type="danger" @click="save(scope.row)">保存</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. </div></div>
  113. </el-scrollbar>
  114. </template>
  115. <script>
  116. import { BASE_API, BUSINESS_BASE_URL } from '@/api/baseUrl'
  117. import {load,paramSetById,deleteMe} from '@/api/report/paramset.js'
  118. export default {
  119. components:{
  120. },
  121. props:{
  122. },
  123. mounted() {
  124. },
  125. created(){
  126. this.loadMe()
  127. },
  128. methods: {
  129. remove(){
  130. let cList = this.json_data.filter(item => item.rowChecked).map(item => item.id)
  131. deleteMe({data:cList.join(",")}).then(response => {
  132. this.loadMe()
  133. })
  134. },
  135. exportExcel() {
  136. require.ensure([], () => {
  137. const { export_json_to_excel } = require('../../business/platform/excel/Export2Excel');
  138. const tHeader = ['编号', '记录表单名称', '程序文件', '填写频率/时机', '填写人', '审核人/审批人', '预期目标', '计算公式'];
  139. const filterVal = ['id', 'formName', 'funcName', 'recRate', 'post', 'auditor', 'checkInd', 'exp'];
  140. const list = this.json_data;
  141. const data = this.formatJson(filterVal, list);
  142. export_json_to_excel(tHeader, data, '监督体系配置');
  143. })
  144. },
  145. formatJson(filterVal, jsonData) {
  146. return jsonData.map(v => filterVal.map(j => v[j]))
  147. },
  148. add() {
  149. this.json_data.push({"rowChecked":false,"id":"","funcName":"","formName":"","recRate":"","post":"","auditor":"","checkInd":"","exp":"","iseditor":true})
  150. },
  151. loadMe(){
  152. let that = this
  153. load().then(response => {
  154. let dbData = response.data
  155. that.json_data=[]
  156. dbData.forEach(function(e){
  157. e['iseditor']=false
  158. that.json_data.push(e)
  159. })
  160. })
  161. },
  162. mySuccess() {
  163. this.$message({
  164. type:'success',
  165. showClose:true,
  166. duration:1000,
  167. message:'上传成功'
  168. });
  169. this.loadMe()
  170. },
  171. edit(row, index) {
  172. row.iseditor = true;
  173. },
  174. save(row, index) {
  175. if(!row.id||row.id==""){
  176. this.$message("ID不能为空!")
  177. return
  178. }
  179. row.iseditor = false;
  180. let that = this
  181. paramSetById(JSON.stringify(row)).then(response => {
  182. that.$message("保存成功!")
  183. this.loadMe()
  184. })
  185. }
  186. },
  187. data() {
  188. return {
  189. height:(window.screen.height-250)+"px",
  190. uploadActionUrl:BASE_API() + BUSINESS_BASE_URL() + '/report/reportset/importFile',
  191. json_fields: {
  192. "编号": "id",
  193. "记录表单名称":"formName",
  194. "程序文件":"funcName",
  195. "填写频率/时机":"recRate",
  196. "填写人":"post",
  197. "审核人/审批人":"auditor",
  198. "预期目标":"checkInd",
  199. "计算公式":"exp",
  200. },
  201. json_data:[],
  202. tableData: [],
  203. json_meta: [
  204. [
  205. {
  206. " key ": " charset ",
  207. " value ": " utf- 8 "
  208. }
  209. ]
  210. ],
  211. }
  212. },
  213. }
  214. </script>
  215. <style lang="scss">
  216. .statistics {
  217. .editDate{
  218. overflow: hidden;
  219. background-color:rgb(249, 255, 255);
  220. }
  221. .block{
  222. float: left;
  223. font-size: 14px;
  224. }
  225. }
  226. </style>