index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="storeAnomaly pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  5. >
  6. <ex-table
  7. v-loading="false"
  8. :table="table"
  9. :data="tableData"
  10. :columns="columns"
  11. :page="pageInfo"
  12. :size="size"
  13. @page-curr-change="handlePageChange"
  14. @page-size-change="handleSizeChange"
  15. @screen-reset="
  16. pageInfo.curr = 1;
  17. parmValue.page = 1;
  18. searchList();
  19. "
  20. @screen-submit="
  21. pageInfo.curr = 1;
  22. parmValue.page = 1;
  23. searchList();
  24. "
  25. >
  26. <template #table-header="{}">
  27. <div style="width: 100%">
  28. <el-row style="padding: 0 0 0 80px">
  29. <el-col :span="3" style="width: 66px; float: right">
  30. <el-button
  31. :size="searchSize"
  32. type="primary"
  33. style="float: right; margin-left: 5px"
  34. @click="openModal('add', false)"
  35. >
  36. 新建
  37. </el-button>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </template>
  42. <template #status="{ scope }">
  43. <el-tag
  44. :size="tablebtnSize"
  45. :type="scope.row.status == '0' ? 'warning' : ''"
  46. v-text="
  47. (statusOptions.find((item) => item.id == scope.row.status) || {})
  48. .label || '--'
  49. "
  50. ></el-tag>
  51. </template>
  52. <template #operation="{ scope }">
  53. <el-tooltip
  54. v-if="powers.some((item) => item == '007')"
  55. effect="dark"
  56. content="详情"
  57. placement="top"
  58. >
  59. <i
  60. class="el-icon-view tb-icon"
  61. @click="openModal(scope.row.id, true, scope.row)"
  62. ></i>
  63. </el-tooltip>
  64. <el-tooltip
  65. v-if="powers.some((item) => item == '005')"
  66. effect="dark"
  67. content="修改"
  68. placement="top"
  69. >
  70. <i
  71. class="el-icon-edit tb-icon"
  72. @click="openModal(scope.row.id, false, scope.row)"
  73. ></i>
  74. </el-tooltip>
  75. <el-tooltip
  76. v-if="
  77. powers.some((item) => item == '004') && scope.row.status === '1'
  78. "
  79. effect="dark"
  80. content="禁用"
  81. placement="top"
  82. >
  83. <i
  84. class="el-icon-video-pause tb-icon"
  85. @click="statusConfirm(scope.row.id, scope.row.status)"
  86. ></i>
  87. </el-tooltip>
  88. <el-tooltip
  89. v-if="
  90. powers.some((item) => item == '004') && scope.row.status === '0'
  91. "
  92. effect="dark"
  93. content="启用"
  94. placement="top"
  95. >
  96. <i
  97. class="el-icon-video-play tb-icon"
  98. @click="statusConfirm(scope.row.id, scope.row.status)"
  99. ></i>
  100. </el-tooltip>
  101. <el-tooltip
  102. v-if="powers.some((item) => item == '006')"
  103. effect="dark"
  104. content="删除"
  105. placement="top"
  106. >
  107. <i
  108. class="el-icon-delete tb-icon"
  109. @click="deleteItem(scope.row.id)"
  110. ></i>
  111. </el-tooltip>
  112. </template>
  113. </ex-table>
  114. <add-edit
  115. :id="modelId"
  116. :sitem="sitem"
  117. :show-model="showModel"
  118. :is-detail="isDetail"
  119. @refresh="searchList"
  120. @cancel="showModel = false"
  121. />
  122. </div>
  123. <div v-else>
  124. <no-auth></no-auth>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. import mixinPage from "@/mixins/elPaginationHandle";
  130. import resToken from "@/mixins/resToken";
  131. import statusList from "@/assets/js/statusList";
  132. import asyncRequest from "@/apis/service/purchaseIn/storeAnomaly";
  133. import addEdit from "./addEdit";
  134. import { mapGetters } from "vuex";
  135. export default {
  136. name: "storeAnomaly",
  137. mixins: [mixinPage, resToken],
  138. components: {
  139. addEdit,
  140. },
  141. computed: {
  142. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  143. powers() {
  144. let tran =
  145. this.$store.getters.btnList.find(
  146. (item) => item.menu_route == "storeAnomaly"
  147. ) || {};
  148. if (tran && tran.action && tran.action.length > 0) {
  149. return tran.action;
  150. } else {
  151. return [];
  152. }
  153. },
  154. },
  155. data() {
  156. return {
  157. // 状态
  158. statusOptions: [
  159. { id: "0", label: "禁用" },
  160. { id: "1", label: "启用" },
  161. ],
  162. statusList: statusList,
  163. loading: true,
  164. showModel: false,
  165. isDetail: false,
  166. modelId: 0,
  167. parmValue: {
  168. status: "", //
  169. page: 1, // 页码
  170. size: 15, // 每页显示条数
  171. },
  172. tableData: [],
  173. passwordModel: false,
  174. passwordModelId: 0,
  175. isPasswordDetail: false,
  176. // 表格 - 数据
  177. tableData: [],
  178. // 表格 - 参数
  179. table: {
  180. stripe: true,
  181. border: true,
  182. _defaultHeader_: ["setcol"],
  183. },
  184. // 表格 - 分页
  185. pageInfo: {
  186. size: 15,
  187. curr: 1,
  188. total: 0,
  189. },
  190. // 表格 - 列参数
  191. columns: [
  192. {
  193. prop: "id",
  194. label: "序列号",
  195. width: "80px",
  196. },
  197. {
  198. prop: "result",
  199. label: "入库验收异常原因",
  200. },
  201. {
  202. prop: "result_desc",
  203. label: "异常描述",
  204. },
  205. {
  206. prop: "status",
  207. label: "状态",
  208. _slot_: "status",
  209. width: "80px",
  210. },
  211. {
  212. prop: "addtime",
  213. label: "创建时间",
  214. sortable: true,
  215. width: "140px",
  216. },
  217. {
  218. prop: "",
  219. label: "操作",
  220. fixed: "right",
  221. _noset_: true,
  222. _slot_: "operation",
  223. width: "150px",
  224. },
  225. ],
  226. };
  227. },
  228. mounted() {
  229. this.searchList();
  230. },
  231. methods: {
  232. async deleteItem(id) {
  233. await this.$confirm("确定要删除?", {
  234. confirmButtonText: "确定",
  235. cancelButtonText: "取消",
  236. type: "warning",
  237. })
  238. .then(async () => {
  239. const model = {
  240. id: id,
  241. };
  242. const res = await asyncRequest.delete(model);
  243. if (res && res.code === 0) {
  244. this.$notify.success({
  245. title: "删除成功",
  246. message: "",
  247. });
  248. this.searchList();
  249. } else if (res && res.code >= 100 && res.code <= 104) {
  250. await this.logout();
  251. } else {
  252. this.$message.warning(res.message);
  253. }
  254. })
  255. .catch(() => {
  256. console.log("取消");
  257. });
  258. },
  259. restSearch() {
  260. this.parmValue = {
  261. status: "", //
  262. page: 1, // 页码
  263. size: 10, // 每页显示条数
  264. };
  265. this.searchList();
  266. },
  267. openModal(id, isDetail, sitem) {
  268. this.showModel = true;
  269. this.modelId = id;
  270. this.isDetail = isDetail;
  271. this.sitem = sitem;
  272. },
  273. async searchList() {
  274. this.loading = true;
  275. const res = await asyncRequest.list(this.parmValue);
  276. if (res && res.code === 0 && res.data) {
  277. this.tableData = res.data.list;
  278. // console.log(this.tableData);
  279. this.pageInfo.total = Number(res.data.count);
  280. } else if (res && res.code >= 100 && res.code <= 104) {
  281. await this.logout();
  282. } else {
  283. this.tableData = [];
  284. this.pageInfo.total = 0;
  285. }
  286. this.loading = false;
  287. },
  288. async statusConfirm(id, status) {
  289. let str = status === "1" ? "禁用" : "启用";
  290. await this.$confirm("确定要改为" + str + "?", {
  291. confirmButtonText: "确定",
  292. cancelButtonText: "取消",
  293. type: "warning",
  294. })
  295. .then(async () => {
  296. this.loading = true;
  297. const model = {
  298. id: id,
  299. status: status === "1" ? "0" : "1",
  300. };
  301. const res = await asyncRequest.status(model);
  302. if (res && res.code === 0) {
  303. this.loading = false;
  304. this.$notify.success({
  305. title: "状态修改成功!",
  306. message: "",
  307. });
  308. await this.searchList();
  309. } else if (res && res.code >= 100 && res.code <= 104) {
  310. await this.logout();
  311. } else {
  312. this.$message.warning(res.message);
  313. }
  314. })
  315. .catch(() => {
  316. console.log("取消");
  317. });
  318. },
  319. },
  320. };
  321. </script>
  322. <style lang="scss" scoped>
  323. </style>