SimpleQuestion.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div>
  3. <crumbs title="独立填写单维护" class="simpleQ-crumb">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="归属:">
  6. <el-select size="mini" v-model="filter.tagAdscription" placeholder="归属" clearable>
  7. <el-option v-if="item.val!=6&&item.val!=7&&item.val!=8&&item.val!=9&&item.val!=10&&item.val!=21&&item.val!=22" v-for="item in Adscriptions" :label="item.name" :value="item.val" :key="item.id" ></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="类型:">
  11. <el-select size="mini" v-model="filter.controlType[0]" placeholder="类型" clearable>
  12. <el-option v-for="item in tagTypes" :label="item.name" :value="item.val" :key="item.id"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="归属组合项:">
  16. <el-input size="mini" v-model="filter.combinationName" placeholder="归属组合项" clearable></el-input>
  17. </el-form-item>
  18. <el-form-item label="填写单界面名称:">
  19. <el-input size="mini" v-model="filter.name" placeholder="填写单界面名称" clearable></el-input>
  20. </el-form-item>
  21. <el-form-item label="填写单系统名称:">
  22. <el-input size="mini" v-model="filter.tagSysName" placeholder="填写单系统名称" clearable></el-input>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button size="mini" @click="filterDatas">确认</el-button>
  26. <el-button size="mini" type="warning" @click="addIndeptTag">添加独立填写单</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </crumbs>
  30. <div class="contents simpleQ-contents">
  31. <el-table
  32. :data="list"
  33. border
  34. style="width: 100%">
  35. <el-table-column
  36. :resizable = "false"
  37. type="index"
  38. :index = 'indexMethod'
  39. label="编号"
  40. width="60">
  41. </el-table-column>
  42. <el-table-column
  43. :resizable = "false"
  44. prop="gmtModified"
  45. label="操作时间"
  46. width="180">
  47. </el-table-column>
  48. <el-table-column
  49. :resizable = "false"
  50. prop="tagName"
  51. label="填写单系统名称">
  52. </el-table-column>
  53. <el-table-column
  54. :resizable = "false"
  55. prop="name"
  56. label="填写单界面名称">
  57. </el-table-column>
  58. <el-table-column
  59. :resizable = "false"
  60. prop="typeCn"
  61. label="归属"
  62. width="80">
  63. </el-table-column>
  64. <el-table-column
  65. :resizable = "false"
  66. prop="tagTypeCn"
  67. label="类型">
  68. </el-table-column>
  69. <el-table-column
  70. :resizable = "false"
  71. prop="combinationName"
  72. label="归属组合项">
  73. </el-table-column>
  74. <el-table-column
  75. :resizable = "false"
  76. prop="modifier"
  77. label="操作人"
  78. width="120">
  79. </el-table-column>
  80. <el-table-column
  81. :resizable = "false"
  82. prop="operate"
  83. label="操作"
  84. width="140">
  85. <template slot-scope="scope">
  86. <el-button @click="modifyIndeptTag(scope.row)" type="text" size="small">修改</el-button>
  87. <span style="margin:0 3px;">|</span>
  88. <el-button @click="copyIndeptTag(scope.row)" type="text" size="small">复制</el-button>
  89. <span style="margin:0 3px;">|</span>
  90. <el-button @click="showDelDialog(scope.row)" class="delete" type="text" size="small">删除</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <el-pagination :current-page.sync="currentPage"
  95. @current-change="currentChange"
  96. background
  97. :page-size="pageSize"
  98. :page-sizes="pageSizeArr"
  99. @size-change="handleSizeChange"
  100. :layout="pageLayout"
  101. :total="total">
  102. </el-pagination>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import api from '@api/preTreat.js';
  108. import config from '@api/config.js';
  109. export default {
  110. name: 'simpleQuestion',
  111. data: function() {
  112. return {
  113. list: [],
  114. tagTypes: [],
  115. Adscriptions: [],
  116. tagTypesList:[],
  117. searched:false,
  118. filter: {
  119. tagType: [], //标签类型
  120. controlType: [],
  121. tagAdscription: '', //标签归属
  122. tagSysName: '', //标签系统名称
  123. combinationName:'',//归属组合项
  124. name:'', //填写单界面名称
  125. },
  126. currentPage: 1,
  127. pageSize: config.pageSize,
  128. pageSizeArr:config.pageSizeArr,
  129. pageLayout:config.pageLayout,
  130. total: 0,
  131. }
  132. },
  133. created() {
  134. this.getDropList();
  135. },
  136. watch:{
  137. 'filter':{
  138. handler:function(){
  139. this.searched = false;
  140. },
  141. deep:true
  142. }
  143. },
  144. beforeRouteEnter(to, from, next){
  145. next(vm => {
  146. //const pm = to.param;
  147. Object.assign(vm,to.params);
  148. })
  149. },
  150. methods: {
  151. handleSizeChange(val){
  152. this.pageSize = val;
  153. this.getDataList();
  154. },
  155. getDropList() {
  156. api.getPreTypeList().then((res) =>{
  157. this.getDataList();
  158. if(res.data.code === '0') {
  159. this.Adscriptions = res.data.data[1];
  160. this.tagTypes = res.data.data[2];
  161. this.tagTypes = this.tagTypes.filter(item => item.val != 0) //去掉名称为默认值的填写单类型
  162. }
  163. })
  164. },
  165. getDataList(isTurnPage) {
  166. const param = this.getFilterItems(isTurnPage);
  167. this.searched = true;
  168. api.getQuestionList(param).then((res) => {
  169. const list = [...res.data.data.records];
  170. for (var i = 0; i < list.length; i++) {
  171. for (var j = 0; j < this.tagTypes.length; j++) {
  172. if(list[i].controlType == this.tagTypes[j].val) {
  173. list[i].tagTypeCn = this.tagTypes[j].name;
  174. }
  175. }
  176. //后台数据typeCn转换为筛选中对应的字段名称
  177. for (var z = 0; z < this.Adscriptions.length; z++) {
  178. if(list[i].type == this.Adscriptions[z].val) {
  179. list[i].typeCn = this.Adscriptions[z].name;
  180. }
  181. }
  182. }
  183. this.list = list;
  184. this.total = res.data.data.total;
  185. })
  186. },
  187. filterDatas() {
  188. this.currentPage = 1;
  189. this.getDataList();
  190. },
  191. addIndeptTag() {
  192. const pam = this.searched?{currentPage:this.currentPage,
  193. pageSize:this.pageSize,
  194. filter:this.filter}:{currentPage:this.currentPage,
  195. pageSize:this.pageSize};
  196. this.$router.push({name:'AddSimpleQuestion',
  197. params:pam})
  198. },
  199. copyIndeptTag(row){
  200. api.questionDetail({id:row.id}).then((res)=>{
  201. const {code,data,msg} = res.data;
  202. if(code=='0'){
  203. const item = Object.assign({},row,data);
  204. const pam = this.searched?{currentPage:this.currentPage,
  205. pageSize:this.pageSize,
  206. filter:this.filter}:{currentPage:this.currentPage,
  207. pageSize:this.pageSize};
  208. this.$router.push({name:'AddSimpleQuestion',params:Object.assign(pam,{isCopy:true,data:item})});
  209. }else{
  210. this.$message({
  211. message: msg,
  212. type: 'warning'
  213. });
  214. }
  215. });
  216. },
  217. modifyIndeptTag(row) {
  218. api.questionDetail({id:row.id}).then((res)=>{
  219. const {code,data,msg} = res.data;
  220. if(code=='0'){
  221. const item = Object.assign({},row,data);
  222. const pam = this.searched?{currentPage:this.currentPage,
  223. pageSize:this.pageSize,
  224. filter:this.filter}:{currentPage:this.currentPage,
  225. pageSize:this.pageSize};
  226. this.$router.push({name:'AddSimpleQuestion',params:Object.assign(pam,{isEdit:true,data:item})});
  227. }else{
  228. this.$message({
  229. message: msg,
  230. type: 'warning'
  231. });
  232. }
  233. });
  234. //this.$router.push({name:'AddIndeptLabel',params:{isEdit:true,data:row}});
  235. },
  236. currentChange(next) {
  237. this.currentPage = next;
  238. this.getDataList(true);
  239. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  240. // this.list = this.cacheData[next];
  241. // } else {
  242. // this.getDataList();
  243. // }
  244. },
  245. clearFilter(){
  246. this.filter = {
  247. tagType: [], //标签类型
  248. controlType: [],
  249. tagAdscription: '', //标签归属
  250. tagSysName: '', //标签系统名称
  251. combinationName:'',//归属组合项
  252. name:'', //填写单界面名称
  253. }
  254. },
  255. getFilterItems(isTurnPage) {
  256. //翻页时筛选条件没点确定则清空
  257. if(isTurnPage&&!this.searched){
  258. this.clearFilter();
  259. };
  260. const param = {
  261. tagTypeList: [1],
  262. callType:1,
  263. current: this.currentPage,
  264. size: this.pageSize,
  265. type: this.filter.tagAdscription,
  266. tagName: this.filter.tagSysName.trim(),
  267. combinationName:this.filter.combinationName.trim(),
  268. name:this.filter.name.trim(),
  269. controlTypeList: this.filter.controlType[0] ? this.filter.controlType: []
  270. };
  271. return param;
  272. },
  273. indexMethod(index) {
  274. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  275. },
  276. getTagType(val) {
  277. return val
  278. },
  279. warning(msg,type){
  280. this.$message({
  281. showClose: true,
  282. message:msg,
  283. type:type||'warning'
  284. })
  285. },
  286. showConfirmDialog(msg,resolve){
  287. this.$alert(msg, '提示', {
  288. confirmButtonText: '确定',
  289. type: 'warning'
  290. }).then(() => {
  291. resolve();
  292. }).catch(() => {});
  293. },
  294. showDelDialog(row){
  295. const param = {
  296. "ids": row.id,
  297. "type": row.type
  298. };
  299. this.showConfirmDialog('是否删除该填写单?',()=>{
  300. api.questionDel(param).then((res)=>{
  301. if(res.data.code=='0'){
  302. if(!this.searched){
  303. //未点确认时清空搜索条件
  304. this.clearFilter();
  305. }
  306. if(this.list.length==1){
  307. //当前在最后一页且只有一条数据时,删除后跳到前一页
  308. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  309. }
  310. this.getDataList();
  311. this.warning(res.data.msg || '操作成功','success');
  312. }else{
  313. this.warning(res.data.msg);
  314. }
  315. }).catch((error)=>{
  316. this.warning(error);
  317. })
  318. });
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="less">
  324. @import "../../less/admin.less";
  325. .delete{
  326. color: red
  327. }
  328. .delete:hover {
  329. color: red;
  330. }
  331. .el-select .el-input .el-icon-arrow-up{
  332. display: inline-block!important;
  333. }
  334. .el-select .el-input .el-icon-circle-close{
  335. float:left;
  336. }
  337. .container.simpleQ-crumb{
  338. height:90px!important;
  339. }
  340. .simpleQ-crumb .contents{
  341. max-width: 870px;
  342. text-align: right;
  343. }
  344. .contents.simpleQ-contents{
  345. padding-top:120px;
  346. }
  347. .simpleQ-crumb .el-form--inline .el-form-item{
  348. margin-bottom: 0;
  349. }
  350. </style>