index.vue 9.3 KB

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