SimpleQuestion.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. import utils from '@api/utils.js';
  110. export default {
  111. name: 'simpleQuestion',
  112. data: function() {
  113. return {
  114. list: [],
  115. tagTypes: [],
  116. Adscriptions: [],
  117. tagTypesList:[],
  118. searched:false,
  119. filter: {
  120. tagType: [], //标签类型
  121. controlType: [],
  122. tagAdscription: '', //标签归属
  123. tagSysName: '', //标签系统名称
  124. combinationName:'',//归属组合项
  125. name:'', //填写单界面名称
  126. },
  127. currentPage: 1,
  128. pageSize: config.pageSize,
  129. pageSizeArr:config.pageSizeArr,
  130. pageLayout:config.pageLayout,
  131. total: 0,
  132. }
  133. },
  134. created() {
  135. this.getDropList();
  136. },
  137. watch:{
  138. 'filter':{
  139. handler:function(){
  140. this.searched = false;
  141. },
  142. deep:true
  143. }
  144. },
  145. beforeRouteEnter(to, from, next){
  146. next(vm => {
  147. //const pm = to.param;
  148. Object.assign(vm,to.params);
  149. vm.inCurrentPage=to.params.currentPage;
  150. })
  151. },
  152. methods: {
  153. handleSizeChange(val){
  154. this.pageSize = val;
  155. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  156. this.getDataList();
  157. },
  158. getDropList() {
  159. api.getPreTypeList().then((res) =>{
  160. this.getDataList();
  161. if(res.data.code === '0') {
  162. this.Adscriptions = res.data.data[1];
  163. this.tagTypes = res.data.data[2];
  164. this.tagTypes = this.tagTypes.filter(item => item.val != 0) //去掉名称为默认值的填写单类型
  165. }
  166. })
  167. },
  168. getDataList(isTurnPage) {
  169. const param = this.getFilterItems(isTurnPage);
  170. this.searched = true;
  171. const loading = this.$loading({
  172. lock: true,
  173. text: 'Loading',
  174. spinner: 'el-icon-loading',
  175. background: 'rgba(0, 0, 0, 0.7)'
  176. });
  177. api.getQuestionList(param).then((res) => {
  178. loading.close()
  179. const list = [...res.data.data.records];
  180. for (var i = 0; i < list.length; i++) {
  181. for (var j = 0; j < this.tagTypes.length; j++) {
  182. if(list[i].controlType == this.tagTypes[j].val) {
  183. list[i].tagTypeCn = this.tagTypes[j].name;
  184. }
  185. }
  186. //后台数据typeCn转换为筛选中对应的字段名称
  187. for (var z = 0; z < this.Adscriptions.length; z++) {
  188. if(list[i].type == this.Adscriptions[z].val) {
  189. list[i].typeCn = this.Adscriptions[z].name;
  190. }
  191. }
  192. }
  193. this.list = list;
  194. this.total = res.data.data.total;
  195. if(this.inCurrentPage!==undefined){
  196. this.currentPage=this.inCurrentPage;
  197. this.inCurrentPage = undefined;
  198. }
  199. })
  200. },
  201. filterDatas() {
  202. this.currentPage = 1;
  203. this.getDataList();
  204. },
  205. addIndeptTag() {
  206. const pam = this.searched?{currentPage:this.currentPage,
  207. pageSize:this.pageSize,
  208. filter:this.filter}:{currentPage:this.currentPage,
  209. pageSize:this.pageSize};
  210. this.$router.push({name:'AddSimpleQuestion',
  211. params:pam})
  212. },
  213. copyIndeptTag(row){
  214. api.questionDetail({id:row.id}).then((res)=>{
  215. const {code,data,msg} = res.data;
  216. if(code=='0'){
  217. const item = Object.assign({},row,data);
  218. const pam = this.searched?{currentPage:this.currentPage,
  219. pageSize:this.pageSize,
  220. filter:this.filter}:{currentPage:this.currentPage,
  221. pageSize:this.pageSize};
  222. this.$router.push({name:'AddSimpleQuestion',params:Object.assign(pam,{isCopy:true,data:item})});
  223. }else{
  224. this.$message({
  225. message: msg,
  226. type: 'warning'
  227. });
  228. }
  229. });
  230. },
  231. modifyIndeptTag(row) {
  232. api.questionDetail({id:row.id}).then((res)=>{
  233. const {code,data,msg} = res.data;
  234. if(code=='0'){
  235. const item = Object.assign({},row,data);
  236. const pam = this.searched?{currentPage:this.currentPage,
  237. pageSize:this.pageSize,
  238. filter:this.filter}:{currentPage:this.currentPage,
  239. pageSize:this.pageSize};
  240. this.$router.push({name:'AddSimpleQuestion',params:Object.assign(pam,{isEdit:true,data:item})});
  241. }else{
  242. this.$message({
  243. message: msg,
  244. type: 'warning'
  245. });
  246. }
  247. });
  248. //this.$router.push({name:'AddIndeptLabel',params:{isEdit:true,data:row}});
  249. },
  250. currentChange(next) {
  251. this.currentPage = next;
  252. this.getDataList(true);
  253. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  254. // this.list = this.cacheData[next];
  255. // } else {
  256. // this.getDataList();
  257. // }
  258. },
  259. clearFilter(){
  260. this.filter = {
  261. tagType: [], //标签类型
  262. controlType: [],
  263. tagAdscription: '', //标签归属
  264. tagSysName: '', //标签系统名称
  265. combinationName:'',//归属组合项
  266. name:'', //填写单界面名称
  267. }
  268. },
  269. getFilterItems(isTurnPage) {
  270. //翻页时筛选条件没点确定则清空
  271. if(isTurnPage&&!this.searched){
  272. this.clearFilter();
  273. };
  274. const param = {
  275. tagTypeList: [1],
  276. callType:1,
  277. current: this.inCurrentPage||this.currentPage,
  278. size: this.pageSize,
  279. type: this.filter.tagAdscription,
  280. tagName: this.filter.tagSysName.trim(),
  281. combinationName:this.filter.combinationName.trim(),
  282. name:this.filter.name.trim(),
  283. controlTypeList: this.filter.controlType[0] ? this.filter.controlType: []
  284. };
  285. return param;
  286. },
  287. indexMethod(index) {
  288. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  289. },
  290. getTagType(val) {
  291. return val
  292. },
  293. warning(msg,type){
  294. this.$message({
  295. showClose: true,
  296. message:msg,
  297. type:type||'warning'
  298. })
  299. },
  300. showConfirmDialog(msg,resolve){
  301. this.$alert(msg, '提示', {
  302. confirmButtonText: '确定',
  303. type: 'warning'
  304. }).then(() => {
  305. resolve();
  306. }).catch(() => {});
  307. },
  308. showDelDialog(row){
  309. const param = {
  310. "ids": row.id,
  311. "type": row.type
  312. };
  313. this.showConfirmDialog('是否删除该填写单?',()=>{
  314. api.questionDel(param).then((res)=>{
  315. if(res.data.code=='0'){
  316. if(!this.searched){
  317. //未点确认时清空搜索条件
  318. this.clearFilter();
  319. }
  320. if(this.list.length==1){
  321. //当前在最后一页且只有一条数据时,删除后跳到前一页
  322. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  323. }
  324. this.getDataList();
  325. this.warning(res.data.msg || '操作成功','success');
  326. }else{
  327. this.warning(res.data.msg);
  328. }
  329. }).catch((error)=>{
  330. this.warning(error);
  331. })
  332. });
  333. }
  334. }
  335. }
  336. </script>
  337. <style lang="less">
  338. @import "../../less/admin.less";
  339. .delete{
  340. color: red
  341. }
  342. .delete:hover {
  343. color: red;
  344. }
  345. .el-select .el-input .el-icon-arrow-up{
  346. display: inline-block!important;
  347. }
  348. .el-select .el-input .el-icon-circle-close{
  349. float:left;
  350. }
  351. .container.simpleQ-crumb{
  352. height:90px!important;
  353. }
  354. .simpleQ-crumb .contents{
  355. max-width: 870px;
  356. text-align: right;
  357. }
  358. .contents.simpleQ-contents{
  359. padding-top:120px;
  360. }
  361. .simpleQ-crumb .el-form--inline .el-form-item{
  362. margin-bottom: 0;
  363. }
  364. </style>