You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
8.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <div class="mod-config">
  3. <div>
  4. <span @click="favoriteFunction()">
  5. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  6. </span>
  7. </div>
  8. <el-button @click="searchList()" type="primary">{{ buttons.search }}</el-button>
  9. <el-button @click="saveColumnList()" type="primary" v-show="showDefault">{{ buttons.defaultTable }}
  10. </el-button>
  11. <el-button @click="userSetting" type="primary">{{ buttons.settingTable }}</el-button>
  12. <el-form v-show="searchShow" :inline="true" :model="queryData" @keyup.enter.native="getDataList()">
  13. <el-form-item label="呆滞天数">
  14. <el-input oninput="value=value.replace(/[^\d]/g,'')" v-model="queryData.day" clearable>
  15. </el-input>
  16. </el-form-item>
  17. <el-form-item label="rollno">
  18. <el-input v-model="queryData.rollno" clearable>
  19. </el-input>
  20. </el-form-item>
  21. <el-form-item label="partno">
  22. <el-input v-model="queryData.partno" clearable>
  23. </el-input>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button @click="getDataList()" type="primary">{{ buttons.search }}</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-table
  30. :height="height"
  31. :data="dataList"
  32. border
  33. v-loading="dataListLoading"
  34. style="width: 100%;">
  35. <el-table-column
  36. v-for="(item,index) in columnList" :key="index"
  37. :sortable="item.columnSortable"
  38. :prop="item.columnProp"
  39. :header-align="item.headerAlign"
  40. :show-overflow-tooltip="item.showOverflowTooltip"
  41. :align="item.align"
  42. :fixed="item.fixed"
  43. :min-width="item.columnWidth"
  44. :label="item.columnLabel">
  45. <template slot-scope="scope">
  46. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  47. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  48. style="width: 100px; height: 80px"/></span>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <!-- 设置列 -->
  53. <column v-if="visible" ref="column" @refreshData="getTableUserColumn"></column>
  54. </div>
  55. </template>
  56. <script>
  57. import AddOrUpdate from './crollinfo-add-or-update'
  58. import {getCRollInfoList} from '@/api/crollinfo/crollinfo.js'
  59. import column from "../common/column";
  60. import search from "../common/search";
  61. import {
  62. searchSysLanguageParam,
  63. searchFunctionButtonList,
  64. saveButtonList,
  65. } from "@/api/sysLanguage.js"
  66. import {
  67. saveTableDefaultList,
  68. getTableDefaultListLanguage,
  69. getTableUserListLanguage
  70. } from "@/api/table.js"
  71. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  72. export default {
  73. data() {
  74. return {
  75. searchVisible: false,
  76. searchShow: false,
  77. // table高度
  78. height: 450,
  79. // 是否收藏
  80. favorite: false,
  81. addLanguage: false,
  82. functionId: 3001,
  83. tableId: "3001SluggishMaterial",
  84. languageCode: this.$i18n.locale,
  85. visible: false,
  86. showDefault: false,
  87. queryData: {
  88. day: '',
  89. rollno: '',
  90. partno: ''
  91. },
  92. // 语言词典集合
  93. sysLanguageParams: [],
  94. columnList: [],
  95. dataList: [],
  96. buttons: {
  97. add: '添加',
  98. edit: '编辑',
  99. delete: '删除',
  100. deleteList: '批量删除',
  101. cz: '操作',
  102. search: '搜索',
  103. download: '导出',
  104. settingTable: '设置列表',
  105. defaultTable: '设置默认配置'
  106. },
  107. dataListLoading: false,
  108. dataListSelections: [],
  109. addOrUpdateVisible: false
  110. }
  111. },
  112. components: {
  113. AddOrUpdate,
  114. column,
  115. search
  116. },
  117. mounted() {
  118. this.$nextTick(() => {
  119. this.height = window.innerHeight - 165;
  120. })
  121. },
  122. activated() {
  123. // this.getDataList()
  124. },
  125. methods: {
  126. // 打开搜索页面
  127. searchList() {
  128. if (this.searchShow) {
  129. this.searchShow = false
  130. return
  131. } else {
  132. this.searchShow = true
  133. }
  134. },
  135. // 获取数据列表
  136. getDataList() {
  137. this.dataListLoading = true
  138. let query = []
  139. let r = {
  140. queryAttributes: "parttypeFlag",
  141. queryType: "string",
  142. queryValue: "R",
  143. }
  144. query.push(r)
  145. let toexpiredays = {
  146. queryAttributes: "toexpiredays",
  147. queryType: "number",
  148. queryValue: this.queryData.day,
  149. }
  150. query.push(toexpiredays)
  151. if (this.queryData.rollno != '') {
  152. let rollno = {
  153. queryAttributes: "rollno",
  154. queryType: "string",
  155. queryValue: this.queryData.rollno,
  156. }
  157. query.push(rollno)
  158. }
  159. if (this.queryData.partno != '') {
  160. let partno = {
  161. queryAttributes: "partno",
  162. queryType: "string",
  163. queryValue: this.queryData.partno,
  164. }
  165. query.push(partno)
  166. }
  167. getCRollInfoList(query).then(({data}) => {
  168. if (data && data.code === 0) {
  169. this.dataList = data.list
  170. }
  171. this.dataListLoading = false
  172. })
  173. // this.searchShow = false
  174. },
  175. // 校验用户是否收藏
  176. favoriteIsOk() {
  177. let userFavorite = {
  178. userId: this.$store.state.user.id,
  179. languageCode: this.$i18n.locale
  180. }
  181. userFavoriteList(userFavorite).then(({data}) => {
  182. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  183. if (size > 0) {
  184. this.favorite = true
  185. } else {
  186. this.favorite = false
  187. }
  188. })
  189. },
  190. // 收藏 OR 取消收藏
  191. favoriteFunction() {
  192. let userFavorite = {
  193. userId: this.$store.state.user.id,
  194. functionId: this.$route.meta.menuId,
  195. }
  196. if (this.favorite) {
  197. // 取消收藏
  198. this.$confirm(`确定取消收藏`, '提示', {
  199. confirmButtonText: '确定',
  200. cancelButtonText: '取消',
  201. type: 'warning'
  202. }).then(() => {
  203. removeUserFavorite(userFavorite).then(({data}) => {
  204. this.$message.success(data.msg)
  205. this.favorite = false
  206. })
  207. })
  208. } else {
  209. // 收藏
  210. saveUserFavorite(userFavorite).then(({data}) => {
  211. this.$message.success(data.msg)
  212. this.favorite = true
  213. })
  214. }
  215. },
  216. // 获取button的词典
  217. getFunctionButtonList() {
  218. let queryButton = {
  219. functionId: this.functionId,
  220. tableId: this.tableId,
  221. languageCode: this.languageCode,
  222. objectType: 'button'
  223. }
  224. searchFunctionButtonList(queryButton).then(({data}) => {
  225. if (data.data.length > 0) {
  226. this.buttons = data.data
  227. }
  228. })
  229. },
  230. // 获取语言词典
  231. getSysLanguageParamList() {
  232. let querySysLanguageParam = {
  233. languageCode: this.$i18n.locale
  234. }
  235. searchSysLanguageParam(querySysLanguageParam).then(({data}) => {
  236. this.sysLanguageParams = data.rows
  237. })
  238. },
  239. // 打开页面设置
  240. userSetting() {
  241. this.visible = true;
  242. let queryTable = {
  243. userId: this.userId,
  244. functionId: this.functionId,
  245. tableId: this.tableId,
  246. languageCode: this.languageCode
  247. }
  248. this.$nextTick(() => {
  249. this.$refs.column.init(queryTable);
  250. });
  251. },
  252. // 获取 用户保存的 格式列
  253. getTableUserColumn() {
  254. let queryTableUser = {
  255. userId: this.userId,
  256. functionId: this.functionId,
  257. tableId: this.tableId,
  258. languageCode: this.languageCode,
  259. status: true,
  260. }
  261. getTableUserListLanguage(queryTableUser).then(({data}) => {
  262. if (data.rows.length > 0) {
  263. //this.columnList = []
  264. this.columnList = data.rows
  265. } else {
  266. this.getColumnList()
  267. }
  268. })
  269. },
  270. // 保存 默认配置 列
  271. saveColumnList() {
  272. this.showDefault = false
  273. saveButtonList(this.buttonList).then(({data}) => {
  274. })
  275. saveTableDefaultList(this.columnList).then(({data}) => {
  276. if (data.code == 0) {
  277. this.$message.success(data.msg)
  278. this.showDefault = false
  279. } else {
  280. this.showDefault = true
  281. this.$message.error(data.msg)
  282. }
  283. })
  284. this.getFunctionButtonList();
  285. this.getColumnList()
  286. },
  287. // 获取 tableDefault 列
  288. getColumnList() {
  289. let queryTable = {
  290. functionId: this.functionId,
  291. tableId: this.tableId,
  292. languageCode: this.languageCode
  293. }
  294. getTableDefaultListLanguage(queryTable).then(({data}) => {
  295. if (!data.rows.length == 0) {
  296. this.showDefault = false
  297. this.columnList = data.rows
  298. } else {
  299. this.showDefault = true
  300. }
  301. })
  302. },
  303. },
  304. created() {
  305. this.getTableUserColumn()
  306. this.getSysLanguageParamList()
  307. this.getFunctionButtonList()
  308. this.favoriteIsOk()
  309. }
  310. }
  311. </script>
  312. <style scoped>
  313. .sl-svg {
  314. overflow: hidden;
  315. float: right;
  316. }
  317. </style>