index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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="orderNumber">
  5. <el-input
  6. v-model="queryParams.orderNumber"
  7. placeholder="请输入单据编号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="是否更新数据" prop="isUpdateData">
  13. <el-select v-model="queryParams.isUpdateData" placeholder="请选择是否更新数据" clearable>
  14. <el-option
  15. v-for="dict in dict.type.sys_yes_no"
  16. :key="dict.value"
  17. :label="dict.label"
  18. :value="dict.value"
  19. />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. v-hasPermi="['inventory:detail:add']"
  36. >新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['inventory:detail:edit']"
  47. >修改</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['inventory:detail:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="el-icon-download"
  65. size="mini"
  66. @click="handleExport"
  67. v-hasPermi="['inventory:detail:export']"
  68. >导出</el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="编号" align="center" prop="id" />
  75. <el-table-column label="单据编号" align="center" prop="orderNumber" />
  76. <el-table-column label="盘点元数据" align="center" prop="inventoryMetadata" />
  77. <el-table-column label="是否更新数据" align="center" prop="isUpdateData">
  78. <template slot-scope="scope">
  79. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUpdateData"/>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="备注" align="center" prop="remark" />
  83. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-edit"
  89. @click="handleUpdate(scope.row)"
  90. v-hasPermi="['inventory:detail:edit']"
  91. >修改</el-button>
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-delete"
  96. @click="handleDelete(scope.row)"
  97. v-hasPermi="['inventory:detail:remove']"
  98. >删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination
  103. v-show="total>0"
  104. :total="total"
  105. :page.sync="queryParams.pageNum"
  106. :limit.sync="queryParams.pageSize"
  107. @pagination="getList"
  108. />
  109. <!-- 添加或修改资产盘点明细对话框 -->
  110. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  111. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  112. <el-form-item label="单据编号" prop="orderNumber">
  113. <el-input v-model="form.orderNumber" placeholder="请输入单据编号" />
  114. </el-form-item>
  115. <el-form-item label="盘点元数据" prop="inventoryMetadata">
  116. <el-input v-model="form.inventoryMetadata" type="textarea" placeholder="请输入内容" />
  117. </el-form-item>
  118. <el-form-item label="是否更新数据" prop="isUpdateData">
  119. <el-select v-model="form.isUpdateData" placeholder="请选择是否更新数据">
  120. <el-option
  121. v-for="dict in dict.type.sys_yes_no"
  122. :key="dict.value"
  123. :label="dict.label"
  124. :value="parseInt(dict.value)"
  125. ></el-option>
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="备注" prop="remark">
  129. <el-input v-model="form.remark" placeholder="请输入备注" />
  130. </el-form-item>
  131. </el-form>
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="submitForm">确 定</el-button>
  134. <el-button @click="cancel">取 消</el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import { listDetail, getDetail, delDetail, addDetail, updateDetail } from "@/api/inventory/detail";
  141. export default {
  142. name: "Detail",
  143. dicts: ['sys_yes_no'],
  144. data() {
  145. return {
  146. // 遮罩层
  147. loading: true,
  148. // 选中数组
  149. ids: [],
  150. // 非单个禁用
  151. single: true,
  152. // 非多个禁用
  153. multiple: true,
  154. // 显示搜索条件
  155. showSearch: true,
  156. // 总条数
  157. total: 0,
  158. // 资产盘点明细表格数据
  159. detailList: [],
  160. // 弹出层标题
  161. title: "",
  162. // 是否显示弹出层
  163. open: false,
  164. // 查询参数
  165. queryParams: {
  166. pageNum: 1,
  167. pageSize: 10,
  168. orderNumber: null,
  169. isUpdateData: null,
  170. },
  171. // 表单参数
  172. form: {},
  173. // 表单校验
  174. rules: {
  175. orderNumber: [
  176. { required: true, message: "单据编号不能为空", trigger: "blur" }
  177. ],
  178. inventoryMetadata: [
  179. { required: true, message: "盘点元数据不能为空", trigger: "blur" }
  180. ],
  181. isUpdateData: [
  182. { required: true, message: "是否更新数据不能为空", trigger: "change" }
  183. ],
  184. }
  185. };
  186. },
  187. created() {
  188. this.getList();
  189. },
  190. methods: {
  191. /** 查询资产盘点明细列表 */
  192. getList() {
  193. this.loading = true;
  194. listDetail(this.queryParams).then(response => {
  195. this.detailList = response.rows;
  196. this.total = response.total;
  197. this.loading = false;
  198. });
  199. },
  200. // 取消按钮
  201. cancel() {
  202. this.open = false;
  203. this.reset();
  204. },
  205. // 表单重置
  206. reset() {
  207. this.form = {
  208. id: null,
  209. orderNumber: null,
  210. inventoryMetadata: null,
  211. isUpdateData: null,
  212. remark: null
  213. };
  214. this.resetForm("form");
  215. },
  216. /** 搜索按钮操作 */
  217. handleQuery() {
  218. this.queryParams.pageNum = 1;
  219. this.getList();
  220. },
  221. /** 重置按钮操作 */
  222. resetQuery() {
  223. this.resetForm("queryForm");
  224. this.handleQuery();
  225. },
  226. // 多选框选中数据
  227. handleSelectionChange(selection) {
  228. this.ids = selection.map(item => item.id)
  229. this.single = selection.length!==1
  230. this.multiple = !selection.length
  231. },
  232. /** 新增按钮操作 */
  233. handleAdd() {
  234. this.reset();
  235. this.open = true;
  236. this.title = "添加资产盘点明细";
  237. },
  238. /** 修改按钮操作 */
  239. handleUpdate(row) {
  240. this.reset();
  241. const id = row.id || this.ids
  242. getDetail(id).then(response => {
  243. this.form = response.data;
  244. this.open = true;
  245. this.title = "修改资产盘点明细";
  246. });
  247. },
  248. /** 提交按钮 */
  249. submitForm() {
  250. this.$refs["form"].validate(valid => {
  251. if (valid) {
  252. if (this.form.id != null) {
  253. updateDetail(this.form).then(response => {
  254. this.$modal.msgSuccess("修改成功");
  255. this.open = false;
  256. this.getList();
  257. });
  258. } else {
  259. addDetail(this.form).then(response => {
  260. this.$modal.msgSuccess("新增成功");
  261. this.open = false;
  262. this.getList();
  263. });
  264. }
  265. }
  266. });
  267. },
  268. /** 删除按钮操作 */
  269. handleDelete(row) {
  270. const ids = row.id || this.ids;
  271. this.$modal.confirm('是否确认删除资产盘点明细编号为"' + ids + '"的数据项?').then(function() {
  272. return delDetail(ids);
  273. }).then(() => {
  274. this.getList();
  275. this.$modal.msgSuccess("删除成功");
  276. }).catch(() => {});
  277. },
  278. /** 导出按钮操作 */
  279. handleExport() {
  280. this.download('inventory/detail/export', {
  281. ...this.queryParams
  282. }, `detail_${new Date().getTime()}.xlsx`)
  283. }
  284. }
  285. };
  286. </script>