SpotcheckContentList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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 @click="handleDetail(record)">详情</a>
  88. <a-divider type="vertical" />
  89. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  90. <a>删除</a>
  91. </a-popconfirm>
  92. <!-- <a-divider type="vertical" />
  93. <a-dropdown>
  94. <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
  95. <a-menu slot="overlay">
  96. <a-menu-item>
  97. <a @click="handleDetail(record)">详情</a>
  98. </a-menu-item>
  99. <a-menu-item>
  100. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  101. <a>删除</a>
  102. </a-popconfirm>
  103. </a-menu-item>
  104. </a-menu>
  105. </a-dropdown> -->
  106. </span>
  107. </a-table>
  108. </div>
  109. <!-- <cmms-spotcheck-content-modal ref="modalForm" @ok="modalFormOk"></cmms-spotcheck-content-modal> -->
  110. <spotcheck-content-modal ref="modalForm" @ok="modalFormOk"></spotcheck-content-modal>
  111. </a-card>
  112. </template>
  113. <script>
  114. import '@/assets/less/TableExpand.less'
  115. import { mixinDevice } from '@/utils/mixin'
  116. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  117. import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  118. import { httpAction, getAction } from '@/api/manage'
  119. import SpotcheckContentModal from './modules/SpotcheckContentModal.vue'
  120. export default {
  121. name: 'SpotcheckContentList',
  122. mixins:[JeecgListMixin, mixinDevice],
  123. components: {
  124. SpotcheckContentModal
  125. },
  126. props: {
  127. selectData: {
  128. type: Object,
  129. default: function(){
  130. return {} // 使用工厂函数返回默认值
  131. }
  132. },
  133. },
  134. data () {
  135. return {
  136. description: '点检内容管理页面',
  137. // 查询参数
  138. queryParam: {},
  139. // 表头
  140. columns: [
  141. {
  142. title: '序号',
  143. dataIndex: '',
  144. key:'rowIndex',
  145. width:60,
  146. align:"center",
  147. customRender:function (t,r,index) {
  148. return parseInt(index)+1;
  149. }
  150. },
  151. {
  152. title:'点检内容编号',
  153. align:"center",
  154. sorter: true,
  155. dataIndex: 'contentcode'
  156. },
  157. {
  158. title:'点检内容名称',
  159. align:"center",
  160. dataIndex: 'contentname'
  161. },
  162. {
  163. title:'设备',
  164. align:"center",
  165. dataIndex: 'equipmentid_dictText'
  166. },
  167. {
  168. title:'状态',
  169. align:"center",
  170. dataIndex: 'status_dictText',
  171. scopedSlots: { customRender: 'status' }
  172. },
  173. {
  174. title:'备注',
  175. align:"center",
  176. dataIndex: 'remark'
  177. },
  178. {
  179. title: '操作',
  180. dataIndex: 'action',
  181. align:"center",
  182. fixed:"right",
  183. width:147,
  184. scopedSlots: { customRender: 'action' }
  185. }
  186. ],
  187. url: {
  188. list: "/cmmsSpotcheckContent/cmmsSpotcheckContent/list",
  189. delete: "/cmmsSpotcheckContent/cmmsSpotcheckContent/delete",
  190. deleteBatch: "/cmmsSpotcheckContent/cmmsSpotcheckContent/deleteBatch",
  191. exportXlsUrl: "/cmmsSpotcheckContent/cmmsSpotcheckContent/exportXls",
  192. importExcelUrl: "cmmsSpotcheckContent/cmmsSpotcheckContent/importExcel",
  193. // edit: "/cmmsSpotcheckContent/cmmsSpotcheckContent/edit",
  194. edit: "/cmmsSpotcheckContent/cmmsSpotcheckContent/editStatus",
  195. },
  196. dictOptions:{},
  197. superFieldList:[],
  198. model: {}
  199. }
  200. },
  201. created() {
  202. this.getSuperFieldList();
  203. },
  204. computed: {
  205. importExcelUrl: function(){
  206. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  207. },
  208. },
  209. methods: {
  210. initDictConfig(){
  211. },
  212. loadData(arg) {
  213. if(!this.url.list){
  214. this.$message.error("请设置url.list属性!")
  215. return
  216. }
  217. //加载数据 若传入参数1则加载第一页的内容
  218. if (arg === 1) {
  219. this.ipagination.current = 1;
  220. }
  221. var params = this.getQueryParams();//查询条件
  222. this.loading = true;
  223. getAction(this.url.list, params).then((res) => {
  224. if (res.success) {
  225. //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
  226. this.dataSource = res.result.records||res.result;
  227. if(res.result.total)
  228. {
  229. this.ipagination.total = res.result.total;
  230. }else{
  231. this.ipagination.total = 0;
  232. }
  233. //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
  234. }else{
  235. this.$message.warning(res.message)
  236. }
  237. }).finally(() => {
  238. this.loading = false
  239. })
  240. },
  241. // 处理父组件传过来的数据
  242. getDataList(){
  243. // console.log(111,this.selectData)
  244. this.queryParam.equipmentid = this.selectData.id
  245. this.loadData()
  246. },
  247. modalFormOk() {
  248. // 新增/修改 成功时,重载列表
  249. this.loadData();
  250. //清空列表选中
  251. this.onClearSelected()
  252. },
  253. getSuperFieldList(){
  254. let fieldList=[];
  255. fieldList.push({type:'string',value:'contentcode',text:'点检内容编号',dictCode:''})
  256. fieldList.push({type:'string',value:'contentname',text:'点检内容名称',dictCode:''})
  257. fieldList.push({type:'sel_search',value:'equipmentid',text:'设备id',dictTable:"tpm_equipment", dictText:'equipmentname', dictCode:'id'})
  258. fieldList.push({type:'string',value:'status',text:'状态:启用:0、禁用:1',dictCode:'spotcheck_content_status'})
  259. this.superFieldList = fieldList
  260. },
  261. statusChange(record,$event){
  262. console.log(record.status,$event)
  263. let text1 = record.status === "0" ? "是否确认停用“" : "是否确认开启“";
  264. let text2 = record.status === "0" ? "”,请确保该设备有可使用的点检内容" : "”,若启用当前点检内容则该设备其他点检内容默认关闭";
  265. const that = this
  266. that.$confirm({
  267. title: "提示",
  268. content: text1 + record.contentname + text2,
  269. onOk() {
  270. let httpurl = '';
  271. let method = 'put';
  272. httpurl+=that.url.edit;
  273. if (record.status == 1) {
  274. that.model = record
  275. that.model.status = 0
  276. } else {
  277. that.model = record
  278. that.model.status = 1
  279. }
  280. httpAction(httpurl,that.model,method).then((res)=>{
  281. if(res.success){
  282. that.$message.success(res.message);
  283. that.modalFormOk()
  284. }else{
  285. that.$message.warning(res.message);
  286. }
  287. })
  288. },
  289. onCancel() {
  290. // that.modalFormOk()
  291. }
  292. });
  293. }
  294. }
  295. }
  296. </script>
  297. <style scoped>
  298. @import '~@assets/less/common.less';
  299. </style>