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.

482 lines
16 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- 收藏 -->
  4. <div>
  5. <span @click="favoriteFunction()">
  6. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  7. </span>
  8. </div>
  9. <!-- 条件查询 -->
  10. <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
  11. <el-form-item :label="'质检员工号'">
  12. <el-input v-model="searchData.inspectorNo" style="width: 120px"></el-input>
  13. </el-form-item>
  14. <el-form-item :label="'质检员姓名'">
  15. <el-input v-model="searchData.inspectorName" style="width: 120px"></el-input>
  16. </el-form-item>
  17. <el-form-item :label="'所处检验工序'">
  18. <el-input v-model="searchData.inspectorType" style="width: 120px"></el-input>
  19. </el-form-item>
  20. <el-form-item :label="'是否在岗'">
  21. <el-select filterable v-model="searchData.inspectorActive" style="width: 120px">
  22. <el-option label="请选择" value=""></el-option>
  23. <el-option label="是" value="Y"></el-option>
  24. <el-option label="否" value="N"></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item :label="' '">
  28. <el-button type="primary" @click="getDataList()">查询</el-button>
  29. <el-button type="primary" @click="addModal()">新增</el-button>
  30. <download-excel
  31. :fields="fields()"
  32. :data="exportData"
  33. type="xls"
  34. :name="exportName"
  35. :header="exportHeader"
  36. :footer="exportFooter"
  37. :fetch="createExportData"
  38. :before-generate="startDownload"
  39. :before-finish="finishDownload"
  40. worksheet="导出信息"
  41. class="el-button el-button--primary el-button--medium">
  42. {{ "导出" }}
  43. </download-excel>
  44. </el-form-item>
  45. </el-form>
  46. <!-- 展示列表 -->
  47. <el-table
  48. :height="height"
  49. :data="dataList"
  50. border
  51. v-loading="dataListLoading"
  52. style="width: 100%;">
  53. <el-table-column
  54. v-for="(item,index) in columnList" :key="index"
  55. :sortable="item.columnSortable"
  56. :prop="item.columnProp"
  57. :header-align="item.headerAlign"
  58. :show-overflow-tooltip="item.showOverflowTooltip"
  59. :align="item.align"
  60. :fixed="item.fixed==''?false:item.fixed"
  61. :min-width="item.columnWidth"
  62. :label="item.columnLabel">
  63. <template slot-scope="scope">
  64. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  65. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column
  69. fixed="right"
  70. header-align="center"
  71. align="center"
  72. width="160"
  73. label="操作">
  74. <template slot-scope="scope">
  75. <a type="text" size="small" @click="updateModal(scope.row)">修改</a>
  76. <a type="text" size="small" @click="deleteModal(scope.row)">删除</a>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. <!-- 新增和修改 -->
  81. <el-dialog title="质检员信息" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="430px">
  82. <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
  83. <el-form-item label="质检员工号:">
  84. <el-input v-model="modalData.inspectorNo" :disabled="modalDisableFlag" style="width: 120px"></el-input>
  85. </el-form-item>
  86. <el-form-item label="质检员姓名:">
  87. <el-input v-model="modalData.inspectorName" style="width: 120px"></el-input>
  88. </el-form-item>
  89. <el-form-item label="质检员电话:">
  90. <el-input v-model="modalData.inspectorPhone" type="number" style="width: 120px"></el-input>
  91. </el-form-item>
  92. <el-form-item :label="'所处检验工序'">
  93. <el-input v-model="modalData.inspectorType" style="width: 120px"></el-input>
  94. </el-form-item>
  95. <el-form-item :label="'是否在岗'">
  96. <el-select filterable v-model="modalData.inspectorActive" style="width: 120px">
  97. <el-option label="是" value="Y"></el-option>
  98. <el-option label="否" value="N"></el-option>
  99. </el-select>
  100. </el-form-item>
  101. </el-form>
  102. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  103. <el-button type="primary" @click="saveData()">保存</el-button>
  104. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  105. </el-footer>
  106. </el-dialog>
  107. </div>
  108. </template>
  109. <script>
  110. import {
  111. inspectorSearch, // 搜索质检员信息
  112. inspectorSave, // 新增质检员信息
  113. inspectorUpdate, // 修改质检员信息
  114. inspectorDelete, // 删除质检员信息
  115. } from "@/api/qc/qc.js"
  116. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  117. export default {
  118. watch: {
  119. searchData: {
  120. deep: true,
  121. handler: function (newV, oldV) {
  122. this.searchData.inspectorNo = this.searchData.inspectorNo.toUpperCase()
  123. }
  124. },
  125. modalData: {
  126. deep: true,
  127. handler: function (newV, oldV) {
  128. this.modalData.inspectorNo = this.modalData.inspectorNo.toUpperCase()
  129. this.modalData.inspectorType = this.modalData.inspectorType.toUpperCase()
  130. }
  131. }
  132. },
  133. data () {
  134. return {
  135. // 是否收藏
  136. favorite: false,
  137. // 导出 start
  138. exportData: [],
  139. exportName: "质检员" + this.dayjs().format('YYYYMMDDHHmmss'),
  140. exportHeader: ["质检员"],
  141. exportFooter: [],
  142. exportList:[],
  143. // 导出 end
  144. searchData: {
  145. inspectorNo: '',
  146. inspectorName: '',
  147. inspectorPhone: '',
  148. inspectorType: '',
  149. inspectorActive: ''
  150. },
  151. height: 200,
  152. dataList: [],
  153. dataListLoading: false,
  154. modalFlag: false,
  155. modalDisableFlag: false,
  156. modalData: {
  157. flag: '',
  158. inspectorNo: '',
  159. inspectorName: '',
  160. inspectorPhone: '',
  161. inspectorType: '',
  162. inspectorActive: ''
  163. },
  164. // 标头展示
  165. columnList: [
  166. {
  167. userId: this.$store.state.user.name,
  168. functionId: 101008,
  169. serialNumber: '101008TableEamPropertiesItemID',
  170. tableId: '101008Table',
  171. tableName: 'common',
  172. columnProp: 'inspectorNo',
  173. headerAlign: 'center',
  174. align: 'left',
  175. columnLabel: '质检员工号',
  176. columnHidden: false,
  177. columnImage: false,
  178. columnSortable: false,
  179. sortLv: 0,
  180. status: true,
  181. fixed: '',
  182. columnWidth: 100
  183. },
  184. {
  185. userId: this.$store.state.user.name,
  186. functionId: 101008,
  187. serialNumber: '101008TableEamPropertiesItemDesc',
  188. tableId: '101008Table',
  189. tableName: 'common',
  190. columnProp: 'inspectorName',
  191. headerAlign: 'center',
  192. align: 'left',
  193. columnLabel: '质检员姓名',
  194. columnHidden: false,
  195. columnImage: false,
  196. columnSortable: false,
  197. sortLv: 0,
  198. status: true,
  199. fixed: '',
  200. columnWidth: 140
  201. },
  202. {
  203. userId: this.$store.state.user.name,
  204. functionId: 101008,
  205. serialNumber: '101008TableEamPropertiesItemDesc',
  206. tableId: '101008Table',
  207. tableName: 'common',
  208. columnProp: 'inspectorPhone',
  209. headerAlign: 'center',
  210. align: 'left',
  211. columnLabel: '质检员电话',
  212. columnHidden: false,
  213. columnImage: false,
  214. columnSortable: false,
  215. sortLv: 0,
  216. status: true,
  217. fixed: '',
  218. columnWidth: 140
  219. },
  220. {
  221. userId: this.$store.state.user.name,
  222. functionId: 101008,
  223. serialNumber: '101008TableEamPropertiesItemDesc',
  224. tableId: '101008Table',
  225. tableName: 'common',
  226. columnProp: 'inspectorType',
  227. headerAlign: 'center',
  228. align: 'left',
  229. columnLabel: '所处检验工序',
  230. columnHidden: false,
  231. columnImage: false,
  232. columnSortable: false,
  233. sortLv: 0,
  234. status: true,
  235. fixed: '',
  236. columnWidth: 140
  237. },
  238. {
  239. userId: this.$store.state.user.name,
  240. functionId: 101008,
  241. serialNumber: '101008TableEamPropertiesItemDesc',
  242. tableId: '101008Table',
  243. tableName: 'common',
  244. columnProp: 'inspectorActive',
  245. headerAlign: 'center',
  246. align: 'left',
  247. columnLabel: '是否在岗',
  248. columnHidden: false,
  249. columnImage: false,
  250. columnSortable: false,
  251. sortLv: 0,
  252. status: true,
  253. fixed: '',
  254. columnWidth: 140
  255. }
  256. ]
  257. }
  258. },
  259. mounted () {
  260. this.$nextTick(() => {
  261. this.height = window.innerHeight - 180
  262. })
  263. },
  264. created () {
  265. this.getDataList()
  266. this.favoriteIsOk()
  267. },
  268. methods: {
  269. // 查询获取数据列表
  270. getDataList () {
  271. inspectorSearch(this.searchData).then(({data}) => {
  272. this.dataList = data.rows
  273. })
  274. },
  275. // 新增按钮
  276. addModal () {
  277. this.modalData = {
  278. flag: '1',
  279. inspectorNo: '',
  280. inspectorName: '',
  281. inspectorPhone: '',
  282. inspectorType: '',
  283. inspectorActive: ''
  284. }
  285. this.modalDisableFlag = false
  286. this.modalFlag = true
  287. },
  288. // 修改按钮
  289. updateModal (row) {
  290. this.modalData = {
  291. flag: '2',
  292. inspectorNo: row.inspectorNo,
  293. inspectorName: row.inspectorName,
  294. inspectorPhone: row.inspectorPhone,
  295. inspectorType: row.inspectorType,
  296. inspectorActive: row.inspectorActive
  297. }
  298. this.modalDisableFlag = true
  299. this.modalFlag = true
  300. },
  301. // 删除方法
  302. deleteModal (row) {
  303. this.$confirm(`是否删除这个质检员信息?`, '提示', {
  304. confirmButtonText: '确定',
  305. cancelButtonText: '取消',
  306. type: 'warning'
  307. }).then(() => {
  308. inspectorDelete(row).then(({data}) => {
  309. if (data && data.code === '0') {
  310. this.getDataList()
  311. this.$message({
  312. message: '操作成功',
  313. type: 'success',
  314. duration: 1500,
  315. onClose: () => {
  316. }
  317. })
  318. } else {
  319. this.$alert(data.msg, '错误', {
  320. confirmButtonText: '确定'
  321. })
  322. }
  323. })
  324. }).catch(() => {
  325. })
  326. },
  327. // 新增/修改方法
  328. saveData () {
  329. if (this.modalData.inspectorNo == '' || this.modalData.inspectorNo == null) {
  330. this.$alert('请输入质检员工号!', '错误', {
  331. confirmButtonText: '确定'
  332. })
  333. return false
  334. }
  335. if (this.modalData.inspectorName == '' || this.modalData.inspectorName == null) {
  336. this.$alert('请输入质检员姓名!', '错误', {
  337. confirmButtonText: '确定'
  338. })
  339. return false
  340. }
  341. if (this.modalData.inspectorPhone == '' || this.modalData.inspectorPhone == null) {
  342. this.$alert('请输入质检员电话!', '错误', {
  343. confirmButtonText: '确定'
  344. })
  345. return false
  346. }
  347. if (this.modalData.inspectorType == '' || this.modalData.inspectorType == null) {
  348. this.$alert('请输入质检员职责!', '错误', {
  349. confirmButtonText: '确定'
  350. })
  351. return false
  352. }
  353. if (this.modalData.inspectorActive == '' || this.modalData.inspectorActive == null) {
  354. this.$alert('请选择质检员是否在岗!', '错误', {
  355. confirmButtonText: '确定'
  356. })
  357. return false
  358. }
  359. if (this.modalData.flag == '1') { // 新增
  360. inspectorSave(this.modalData).then(({data}) => {
  361. if (data && data.code === '0') {
  362. this.getDataList()
  363. this.modalFlag = false
  364. this.$message({
  365. message: '操作成功',
  366. type: 'success',
  367. duration: 1500,
  368. onClose: () => {
  369. }
  370. })
  371. } else {
  372. this.$alert(data.msg, '错误', {
  373. confirmButtonText: '确定'
  374. })
  375. }
  376. })
  377. } else { // 修改
  378. inspectorUpdate(this.modalData).then(({data}) => {
  379. if (data && data.code === '0') {
  380. this.getDataList()
  381. this.modalFlag = false
  382. this.$message({
  383. message: '操作成功',
  384. type: 'success',
  385. duration: 1500,
  386. onClose: () => {
  387. }
  388. })
  389. } else {
  390. this.$alert(data.msg, '错误', {
  391. confirmButtonText: '确定'
  392. })
  393. }
  394. })
  395. }
  396. },
  397. // 校验用户是否收藏
  398. favoriteIsOk() {
  399. let userFavorite = {
  400. userId: this.$store.state.user.id,
  401. languageCode: this.$i18n.locale
  402. }
  403. console.log(this.$route.meta.menuId)
  404. userFavoriteList(userFavorite).then(({data}) => {
  405. for (let i = 0; i < data.list.length; i++) {
  406. // let flag=false;
  407. if(this.$route.meta.menuId==data.list[i].menuId){
  408. this.favorite = true
  409. // flag=true;
  410. }
  411. }
  412. })
  413. },
  414. // 收藏 OR 取消收藏
  415. favoriteFunction() {
  416. let userFavorite = {
  417. userId: this.$store.state.user.id,
  418. functionId: this.$route.meta.menuId,
  419. }
  420. if (this.favorite) {
  421. // 取消收藏
  422. // this.$confirm(`确定取消收藏`, '提示', {
  423. // confirmButtonText: '确定',
  424. // cancelButtonText: '取消',
  425. // type: 'warning'
  426. // }).then(() => {
  427. removeUserFavorite(userFavorite).then(({data}) => {
  428. this.$message.success(data.msg)
  429. this.favorite = false
  430. })
  431. // })
  432. } else {
  433. // 收藏
  434. saveUserFavorite(userFavorite).then(({data}) => {
  435. this.$message.success(data.msg)
  436. this.favorite = true
  437. })
  438. }
  439. },
  440. //导出excel
  441. async createExportData() {
  442. this.searchData.limit = -1
  443. this.searchData.page = 1
  444. await inspectorSearch(this.searchData).then(({data}) => {
  445. this.exportList= data.rows;
  446. })
  447. return this.exportList;
  448. },
  449. startDownload() {
  450. // this.exportData = this.dataList
  451. },
  452. finishDownload() {
  453. },
  454. fields() {
  455. let json = "{"
  456. this.columnList.forEach((item, index) => {
  457. if (index == this.columnList.length - 1) {
  458. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  459. } else {
  460. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  461. }
  462. })
  463. json += "}"
  464. let s = eval("(" + json + ")")
  465. return s
  466. },
  467. // 导出 end
  468. }
  469. }
  470. </script>