综合办公系统
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.

index.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="设备状态" prop="status">
  5. <el-select v-model="queryParams.status" clearable @keyup.enter.native="handleQuery">
  6. <el-option key="0" label="被领用" value="0">
  7. </el-option>
  8. <el-option key="1" label="可领用" value="1">
  9. </el-option>
  10. <el-option key="2" label="维修中" value="2">
  11. </el-option>
  12. <el-option key="3" label="已停用" value="3">
  13. </el-option>
  14. <el-option key="4" label="已报废" value="4">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="设备名称" prop="name">
  19. <el-input v-model="queryParams.name" placeholder="请输入设备名称" clearable @keyup.enter.native="handleQuery" />
  20. </el-form-item>
  21. <el-form-item label="设备品牌" prop="brand">
  22. <el-input v-model="queryParams.brand" placeholder="请输入设备品牌" clearable @keyup.enter.native="handleQuery" />
  23. </el-form-item>
  24. <el-form-item label="规格型号" prop="series">
  25. <el-input v-model="queryParams.series" placeholder="请输入规格型号" clearable @keyup.enter.native="handleQuery" />
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  35. v-hasPermi="['oa:device:add']">新增</el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  39. v-hasPermi="['oa:device:edit']">修改</el-button>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  43. v-hasPermi="['oa:device:remove']">删除</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  47. v-hasPermi="['oa:device:export']">导出</el-button>
  48. </el-col>
  49. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  50. </el-row>
  51. <el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange">
  52. <el-table-column type="selection" width="55" align="center" />
  53. <!-- <el-table-column label="设备id" align="center" prop="deviceId" /> -->
  54. <el-table-column label="设备状态" align="center" prop="status">
  55. <template slot-scope="scope">
  56. <el-tag :type="statusTypeStyle(scope.row.status)">{{ statusTypeText(scope.row.status) }}</el-tag>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="出厂编号" align="center" prop="code" />
  60. <el-table-column label="设备名称" align="center" prop="name" />
  61. <el-table-column label="设备类别" align="center" prop="type" />
  62. <el-table-column label="设备品牌" align="center" prop="brand" />
  63. <el-table-column label="规格型号" align="center" prop="series" />
  64. <el-table-column label="购置时间" align="center" prop="acquisitionTime" width="180">
  65. <template slot-scope="scope">
  66. <span>{{ parseTime(scope.row.acquisitionTime, '{y}-{m}-{d}') }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="购买价格(元)" align="center" prop="cost" />
  70. <el-table-column label="预计使用年限" align="center" prop="expectLife" />
  71. <el-table-column label="单日成本(元)" align="center" prop="dayCost" />
  72. <el-table-column label="存放地点" align="center" prop="place" />
  73. <el-table-column label="管理部门" align="center" prop="dept.deptName" />
  74. <el-table-column label="备注" align="center" prop="remark" />
  75. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  76. <template slot-scope="scope">
  77. <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAddDetail(scope.row)"
  78. v-hasPermi="['oa:car:edit']">添加明细</el-button>
  79. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  80. v-hasPermi="['oa:device:edit']">修改</el-button>
  81. <el-button size="mini" type="text" icon="el-icon-delete" style="color: #fc0000;"
  82. @click="handleDelete(scope.row)" v-hasPermi="['oa:device:remove']">删除</el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  87. @pagination="getList" />
  88. <!-- 添加或修改cmc设备信息对话框 -->
  89. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  90. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  91. <el-row :gutter="20">
  92. <el-col :span="12">
  93. <el-form-item label="出厂编号" prop="code">
  94. <el-input v-model="form.code" placeholder="请输入出厂编号" />
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="12">
  98. <el-form-item label="设备名称" prop="name">
  99. <el-input v-model="form.name" placeholder="请输入设备名称" />
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. <el-row :gutter="20">
  104. <el-col :span="12">
  105. <el-form-item label="购置时间" prop="acquisitionTime">
  106. <el-date-picker clearable v-model="form.acquisitionTime" type="date" value-format="yyyy-MM-dd"
  107. placeholder="请选择购置时间">
  108. </el-date-picker>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="12">
  112. <el-form-item label="规格型号" prop="series">
  113. <el-input v-model="form.series" placeholder="请输入规格型号" />
  114. </el-form-item>
  115. </el-col>
  116. </el-row>
  117. <el-row :gutter="20">
  118. <el-col :span="12">
  119. <el-form-item label="预计使用年限" prop="expectLife">
  120. <el-input v-model="form.expectLife" placeholder="请输入年限" style="width:130px;margin-right:10px;" />
  121. <span>年</span>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="12">
  125. <el-form-item label="购买价格" prop="cost">
  126. <el-input style="width:130px;margin-right:10px;" v-model="form.cost" placeholder="请输入金额" />
  127. <span>元</span>
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-row :gutter="20">
  132. <el-col :span="12">
  133. <el-form-item label="设备品牌" prop="brand">
  134. <el-input v-model="form.brand" placeholder="请输入设备品牌" />
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="12">
  138. <el-form-item label="单日成本" prop="dayCost">
  139. <el-input v-model="form.dayCost" placeholder="请输入单日成本" />
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. <el-row :gutter="20">
  144. <el-col :span="12">
  145. <el-form-item label="存放地点" prop="place">
  146. <el-input v-model="form.place" placeholder="请输入存放地点" />
  147. </el-form-item>
  148. </el-col>
  149. <el-col :span="12">
  150. <el-form-item label="设备类别" prop="place">
  151. <el-input v-model="form.type" placeholder="请输入设备类别" />
  152. </el-form-item>
  153. </el-col>
  154. </el-row>
  155. <el-form-item label="管理部门" prop="dept.deptName">
  156. <el-input v-model="form.deptName" placeholder="请输入管理部门" />
  157. </el-form-item>
  158. <el-row :gutter="20">
  159. <el-col :span="24">
  160. <el-form-item label="备注" prop="remark">
  161. <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
  162. </el-form-item>
  163. </el-col>
  164. </el-row>
  165. </el-form>
  166. <div slot="footer" class="dialog-footer">
  167. <el-button type="primary" @click="submitForm">确 定</el-button>
  168. <el-button @click="cancel">取 消</el-button>
  169. </div>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script>
  174. import { listDevice, getDevice, delDevice, addDevice, updateDevice } from "@/api/oa/device/device";
  175. export default {
  176. name: "Device",
  177. data() {
  178. return {
  179. // 遮罩层
  180. loading: true,
  181. // 选中数组
  182. ids: [],
  183. // 非单个禁用
  184. single: true,
  185. // 非多个禁用
  186. multiple: true,
  187. // 显示搜索条件
  188. showSearch: true,
  189. // 总条数
  190. total: 0,
  191. // cmc设备信息表格数据
  192. deviceList: [],
  193. // 弹出层标题
  194. title: "",
  195. // 是否显示弹出层
  196. open: false,
  197. // 查询参数
  198. queryParams: {
  199. pageNum: 1,
  200. pageSize: 10,
  201. code: null,
  202. type: '办公设备',
  203. acquisitionTime: null,
  204. cost: null,
  205. expectLife: null,
  206. series: null
  207. },
  208. // 表单参数
  209. form: {},
  210. // 表单校验
  211. rules: {
  212. }
  213. };
  214. },
  215. created() {
  216. this.getList();
  217. },
  218. methods: {
  219. /** 查询cmc设备信息列表 */
  220. getList() {
  221. this.loading = true;
  222. listDevice(this.queryParams).then(response => {
  223. this.deviceList = response.rows;
  224. this.total = response.total;
  225. this.loading = false;
  226. });
  227. },
  228. // 取消按钮
  229. cancel() {
  230. this.open = false;
  231. this.reset();
  232. },
  233. // 表单重置
  234. reset() {
  235. this.form = {
  236. deviceId: null,
  237. code: null,
  238. type: null,
  239. acquisitionTime: null,
  240. cost: null,
  241. expectLife: null,
  242. series: null
  243. };
  244. this.resetForm("form");
  245. },
  246. /** 搜索按钮操作 */
  247. handleQuery() {
  248. this.queryParams.pageNum = 1;
  249. this.getList();
  250. },
  251. /** 重置按钮操作 */
  252. resetQuery() {
  253. this.resetForm("queryForm");
  254. this.handleQuery();
  255. },
  256. // 多选框选中数据
  257. handleSelectionChange(selection) {
  258. this.ids = selection.map(item => item.deviceId)
  259. this.single = selection.length !== 1
  260. this.multiple = !selection.length
  261. },
  262. /** 新增按钮操作 */
  263. handleAdd() {
  264. this.reset();
  265. this.open = true;
  266. this.title = "添加设备信息";
  267. },
  268. // 新增明细按钮
  269. handleAddDetail(row) {
  270. this.$router.push({
  271. path: '/device/detail',
  272. query: {
  273. type: 'supply',
  274. deviceId: row.deviceId,
  275. }
  276. })
  277. },
  278. /** 修改按钮操作 */
  279. handleUpdate(row) {
  280. this.reset();
  281. const deviceId = row.deviceId || this.ids
  282. getDevice(deviceId).then(response => {
  283. this.form = response.data;
  284. this.open = true;
  285. this.title = "修改设备信息";
  286. });
  287. },
  288. /** 提交按钮 */
  289. submitForm() {
  290. this.$refs["form"].validate(valid => {
  291. if (valid) {
  292. if (this.form.deviceId != null) {
  293. updateDevice(this.form).then(response => {
  294. this.$modal.msgSuccess("修改成功");
  295. this.open = false;
  296. this.getList();
  297. });
  298. } else {
  299. addDevice(this.form).then(response => {
  300. this.$modal.msgSuccess("新增成功");
  301. this.open = false;
  302. this.getList();
  303. });
  304. }
  305. }
  306. });
  307. },
  308. /** 删除按钮操作 */
  309. handleDelete(row) {
  310. const deviceIds = row.deviceId || this.ids;
  311. const code = row.code
  312. this.$modal.confirm('是否确认删除设备编号为【"' + code + '"】的设备数据?').then(function () {
  313. return delDevice(deviceIds);
  314. }).then(() => {
  315. this.getList();
  316. this.$modal.msgSuccess("删除成功");
  317. }).catch(() => { });
  318. },
  319. /** 导出按钮操作 */
  320. handleExport() {
  321. this.download('oa/device/export', {
  322. ...this.queryParams
  323. }, `device_${new Date().getTime()}.xlsx`)
  324. },
  325. statusTypeText(row) {
  326. if (row == '0') {
  327. return '被领用'
  328. }
  329. if (row == '1') {
  330. return '可领用'
  331. }
  332. if (row == '2') {
  333. return '维修中'
  334. }
  335. if (row == '3') {
  336. return '已停用'
  337. }
  338. if (row == '4') {
  339. return '已报废'
  340. }
  341. },
  342. statusTypeStyle(row) {
  343. if (row == '0') {
  344. return 'warning'
  345. }
  346. if (row == '1') {
  347. return 'success'
  348. }
  349. if (row == '2') {
  350. return 'danger'
  351. }
  352. if (row == '3') {
  353. return 'primary'
  354. }
  355. if (row == '4') {
  356. return 'info'
  357. }
  358. }
  359. }
  360. };
  361. </script>