SpotcheckContentList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  8. <a-form-item label="点检内容名称">
  9. <a-input v-model="queryParam.contentname" placeholder="请输入点检内容名称"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  13. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  15. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <!-- 查询区域-END -->
  22. <!-- 操作按钮区域 -->
  23. <div class="table-operator">
  24. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  25. <!-- <a-button type="primary" icon="download" @click="handleExportXls('点检内容')">导出</a-button>
  26. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  27. <a-button type="primary" icon="import">导入</a-button>
  28. </a-upload> -->
  29. <!-- 高级查询区域 -->
  30. <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query> -->
  31. <a-dropdown v-if="selectedRowKeys.length > 0">
  32. <a-menu slot="overlay">
  33. <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
  34. </a-menu>
  35. <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
  36. </a-dropdown>
  37. </div>
  38. <!-- table区域-begin -->
  39. <div>
  40. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  41. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  42. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  43. </div>
  44. <a-table
  45. ref="table"
  46. size="middle"
  47. :scroll="{x:true}"
  48. bordered
  49. rowKey="id"
  50. :columns="columns"
  51. :dataSource="dataSource"
  52. :pagination="ipagination"
  53. :loading="loading"
  54. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  55. class="j-table-force-nowrap"
  56. @change="handleTableChange">
  57. <template slot="status" slot-scope="text, record">
  58. <!-- {{ record.status }} -->
  59. <!-- <a-popconfirm title="确定删除吗?" @confirm="() => statusChange(record)">
  60. <a-switch :default-checked= "record.status == 0 ? true : false" @change="statusChange(record,$event)" />
  61. </a-popconfirm> -->
  62. <a-switch :checked= "record.status == 0 ? true : false" @click="statusChange(record,$event)" />
  63. <!-- <a-switch checkedChildren="禁用" unCheckedChildren="启用" :default-checked= "record.status == 0 ? true : false" @change="statusChange(record,$event)" /> -->
  64. </template>
  65. <template slot="htmlSlot" slot-scope="text">
  66. <div v-html="text"></div>
  67. </template>
  68. <template slot="imgSlot" slot-scope="text,record">
  69. <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
  70. <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
  71. </template>
  72. <template slot="fileSlot" slot-scope="text">
  73. <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
  74. <a-button
  75. v-else
  76. :ghost="true"
  77. type="primary"
  78. icon="download"
  79. size="small"
  80. @click="downloadFile(text)">
  81. 下载
  82. </a-button>
  83. </template>
  84. <span slot="action" slot-scope="text, record">
  85. <a @click="handleEdit(record)">编辑</a>
  86. <a-divider type="vertical" />
  87. <a-dropdown>
  88. <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
  89. <a-menu slot="overlay">
  90. <a-menu-item>
  91. <a @click="handleDetail(record)">详情</a>
  92. </a-menu-item>
  93. <a-menu-item>
  94. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  95. <a>删除</a>
  96. </a-popconfirm>
  97. </a-menu-item>
  98. </a-menu>
  99. </a-dropdown>
  100. </span>
  101. </a-table>
  102. </div>
  103. <!-- <cmms-spotcheck-content-modal ref="modalForm" @ok="modalFormOk"></cmms-spotcheck-content-modal> -->
  104. <spotcheck-content-modal ref="modalForm" @ok="modalFormOk"></spotcheck-content-modal>
  105. </a-card>
  106. </template>
  107. <script>
  108. import '@/assets/less/TableExpand.less'
  109. import { mixinDevice } from '@/utils/mixin'
  110. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  111. import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  112. import { httpAction, getAction } from '@/api/manage'
  113. import SpotcheckContentModal from './modules/SpotcheckContentModal.vue'
  114. export default {
  115. name: 'SpotcheckContentList',
  116. mixins:[JeecgListMixin, mixinDevice],
  117. components: {
  118. SpotcheckContentModal
  119. },
  120. props: {
  121. selectData: {
  122. type: Object,
  123. default: function(){
  124. return {} // 使用工厂函数返回默认值
  125. }
  126. },
  127. },
  128. data () {
  129. return {
  130. description: '点检内容管理页面',
  131. // 查询参数
  132. queryParam: {},
  133. // 表头
  134. columns: [
  135. {
  136. title: '序号',
  137. dataIndex: '',
  138. key:'rowIndex',
  139. width:60,
  140. align:"center",
  141. customRender:function (t,r,index) {
  142. return parseInt(index)+1;
  143. }
  144. },
  145. {
  146. title:'点检内容编号',
  147. align:"center",
  148. dataIndex: 'contentcode'
  149. },
  150. {
  151. title:'点检内容名称',
  152. align:"center",
  153. dataIndex: 'contentname'
  154. },
  155. {
  156. title:'设备',
  157. align:"center",
  158. dataIndex: 'equipmentid_dictText'
  159. },
  160. {
  161. title:'状态',
  162. align:"center",
  163. dataIndex: 'status_dictText',
  164. scopedSlots: { customRender: 'status' }
  165. },
  166. {
  167. title:'备注',
  168. align:"center",
  169. dataIndex: 'remark'
  170. },
  171. {
  172. title: '操作',
  173. dataIndex: 'action',
  174. align:"center",
  175. fixed:"right",
  176. width:147,
  177. scopedSlots: { customRender: 'action' }
  178. }
  179. ],
  180. url: {
  181. list: "/cmmsSpotcheckContent/cmmsSpotcheckContent/list",
  182. delete: "/cmmsSpotcheckContent/cmmsSpotcheckContent/delete",
  183. deleteBatch: "/cmmsSpotcheckContent/cmmsSpotcheckContent/deleteBatch",
  184. exportXlsUrl: "/cmmsSpotcheckContent/cmmsSpotcheckContent/exportXls",
  185. importExcelUrl: "cmmsSpotcheckContent/cmmsSpotcheckContent/importExcel",
  186. // edit: "/cmmsSpotcheckContent/cmmsSpotcheckContent/edit",
  187. edit: "/cmmsSpotcheckContent/cmmsSpotcheckContent/editStatus",
  188. },
  189. dictOptions:{},
  190. superFieldList:[],
  191. model: {}
  192. }
  193. },
  194. created() {
  195. this.getSuperFieldList();
  196. },
  197. computed: {
  198. importExcelUrl: function(){
  199. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  200. },
  201. },
  202. methods: {
  203. initDictConfig(){
  204. },
  205. loadData(arg) {
  206. if(!this.url.list){
  207. this.$message.error("请设置url.list属性!")
  208. return
  209. }
  210. //加载数据 若传入参数1则加载第一页的内容
  211. if (arg === 1) {
  212. this.ipagination.current = 1;
  213. }
  214. var params = this.getQueryParams();//查询条件
  215. this.loading = true;
  216. getAction(this.url.list, params).then((res) => {
  217. if (res.success) {
  218. //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
  219. this.dataSource = res.result.records||res.result;
  220. if(res.result.total)
  221. {
  222. this.ipagination.total = res.result.total;
  223. }else{
  224. this.ipagination.total = 0;
  225. }
  226. //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
  227. }else{
  228. this.$message.warning(res.message)
  229. }
  230. }).finally(() => {
  231. this.loading = false
  232. })
  233. },
  234. // 处理父组件传过来的数据
  235. getDataList(){
  236. // console.log(111,this.selectData)
  237. this.queryParam.equipmentid = this.selectData.id
  238. this.loadData()
  239. },
  240. modalFormOk() {
  241. // 新增/修改 成功时,重载列表
  242. this.loadData();
  243. //清空列表选中
  244. this.onClearSelected()
  245. },
  246. getSuperFieldList(){
  247. let fieldList=[];
  248. fieldList.push({type:'string',value:'contentcode',text:'点检内容编号',dictCode:''})
  249. fieldList.push({type:'string',value:'contentname',text:'点检内容名称',dictCode:''})
  250. fieldList.push({type:'sel_search',value:'equipmentid',text:'设备id',dictTable:"tpm_equipment", dictText:'equipmentname', dictCode:'id'})
  251. fieldList.push({type:'string',value:'status',text:'状态:启用:0、禁用:1',dictCode:'spotcheck_content_status'})
  252. this.superFieldList = fieldList
  253. },
  254. statusChange(record,$event){
  255. console.log(record.status,$event)
  256. let text1 = record.status === "0" ? "是否确认停用“" : "是否确认开启“";
  257. let text2 = record.status === "0" ? "”,请确保该设备有可使用的点检内容" : "”,若启用当前点检内容则该设备其他点检内容默认关闭";
  258. const that = this
  259. that.$confirm({
  260. title: "提示",
  261. content: text1 + record.contentname + text2,
  262. onOk() {
  263. let httpurl = '';
  264. let method = 'put';
  265. httpurl+=that.url.edit;
  266. if (record.status == 1) {
  267. that.model = record
  268. that.model.status = 0
  269. } else {
  270. that.model = record
  271. that.model.status = 1
  272. }
  273. httpAction(httpurl,that.model,method).then((res)=>{
  274. if(res.success){
  275. that.$message.success(res.message);
  276. that.modalFormOk()
  277. }else{
  278. that.$message.warning(res.message);
  279. }
  280. })
  281. },
  282. onCancel() {
  283. // that.modalFormOk()
  284. }
  285. });
  286. }
  287. }
  288. }
  289. </script>
  290. <style scoped>
  291. @import '~@assets/less/common.less';
  292. </style>