index.vue 10.0 KB

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