index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div class="workCompany 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 10px 80px">
  29. <!-- 创建时间 -->
  30. <el-col :span="18" style="width: 303px; padding: 0">
  31. <period-date-picker
  32. :start="parmValue.start"
  33. :end="parmValue.end"
  34. :type="1"
  35. :width="'135px'"
  36. :title="'创建'"
  37. :size="searchSize"
  38. @numReturned="numReturned($event, 0)"
  39. />
  40. </el-col>
  41. <el-col :span="18" style="width: 420px; padding: 0">
  42. <el-input
  43. placeholder="关键字"
  44. v-model="input"
  45. :size="searchSize"
  46. class="input-with-select"
  47. >
  48. <el-select
  49. v-model="select"
  50. slot="prepend"
  51. style="width: 125px"
  52. placeholder="请选择类型"
  53. >
  54. <el-option label="仓库编码" value="1"></el-option>
  55. <el-option label="负责人姓名" value="2"></el-option>
  56. <el-option label="负责人手机号" value="3"></el-option>
  57. </el-select>
  58. <el-button
  59. slot="append"
  60. icon="el-icon-search"
  61. @click="searchList"
  62. ></el-button>
  63. </el-input>
  64. </el-col>
  65. <el-col :span="4" style="width: 66px; padding-left: 10px">
  66. <el-button
  67. type="warning"
  68. class="fl"
  69. :size="searchSize"
  70. @click="restSearch"
  71. >
  72. 重置
  73. </el-button>
  74. </el-col>
  75. <el-col
  76. :span="3"
  77. style="width: 56px; margin-left: 10px"
  78. class="fr"
  79. >
  80. <el-button
  81. :size="searchSize"
  82. type="primary"
  83. @click="searchList"
  84. >
  85. 刷新
  86. </el-button>
  87. </el-col>
  88. </el-row>
  89. <el-row style="padding: 0">
  90. <el-col :span="18" style="width: 340px; padding: 0">
  91. <search-customer
  92. :size="searchSize"
  93. :code="supplierNo"
  94. :placeholder="'供应商公司名称'"
  95. :is-detail="false"
  96. :disabled="false"
  97. :names="''"
  98. @searchChange="supplierChange"
  99. />
  100. </el-col>
  101. <el-col
  102. :span="3"
  103. style="width: 56px"
  104. class="mr10 fr"
  105. v-if="powers.some((item) => item == '003')"
  106. >
  107. <el-button
  108. class="fl"
  109. :size="searchSize"
  110. type="success"
  111. @click="openModal('add', false)"
  112. >
  113. 新建
  114. </el-button>
  115. </el-col>
  116. </el-row>
  117. </div>
  118. </template>
  119. <template #status="{ scope }">
  120. <el-tag
  121. :size="tablebtnSize"
  122. :type="scope.row.status == '0' ? 'warning' : ''"
  123. v-text="
  124. (statusOptions.find((item) => item.id == scope.row.status) || {})
  125. .label || '--'
  126. "
  127. ></el-tag>
  128. </template>
  129. <template #operation="{ scope }">
  130. <el-tooltip
  131. v-if="powers.some((item) => item == '007')"
  132. effect="dark"
  133. content="详情"
  134. placement="top"
  135. >
  136. <i
  137. class="el-icon-view tb-icon"
  138. @click="openModal(scope.row.id, true)"
  139. ></i>
  140. </el-tooltip>
  141. <el-tooltip
  142. v-if="powers.some((item) => item == '005')"
  143. effect="dark"
  144. content="修改"
  145. placement="top"
  146. >
  147. <i
  148. class="el-icon-edit tb-icon"
  149. @click="openModal(scope.row.id, false)"
  150. ></i>
  151. </el-tooltip>
  152. <el-tooltip
  153. v-if="
  154. powers.some((item) => item == '004') && scope.row.status === '1'
  155. "
  156. effect="dark"
  157. content="禁用"
  158. placement="top"
  159. >
  160. <i
  161. class="el-icon-video-pause tb-icon"
  162. @click="statusConfirm(scope.row.id, scope.row.status)"
  163. ></i>
  164. </el-tooltip>
  165. <el-tooltip
  166. v-if="
  167. powers.some((item) => item == '004') && scope.row.status === '0'
  168. "
  169. effect="dark"
  170. content="启用"
  171. placement="top"
  172. >
  173. <i
  174. class="el-icon-video-play tb-icon"
  175. @click="statusConfirm(scope.row.id, scope.row.status)"
  176. ></i>
  177. </el-tooltip>
  178. <el-tooltip
  179. v-if="powers.some((item) => item == '006')"
  180. effect="dark"
  181. content="删除"
  182. placement="top"
  183. >
  184. <i
  185. class="el-icon-delete tb-icon"
  186. @click="deleteById(scope.row.id, scope.row.status)"
  187. ></i>
  188. </el-tooltip>
  189. </template>
  190. </ex-table>
  191. <add-edit
  192. :id="modelId"
  193. :show-model="showModel"
  194. :is-detail="isDetail"
  195. @refresh="searchList"
  196. @cancel="showModel = false"
  197. />
  198. </div>
  199. <div v-else>
  200. <no-auth></no-auth>
  201. </div>
  202. </div>
  203. </template>
  204. <script>
  205. import mixinPage from "@/mixins/elPaginationHandle";
  206. import resToken from "@/mixins/resToken";
  207. import asyncRequest from "@/apis/service/serviceParam/workCompany";
  208. import addEdit from "./addEdit";
  209. import { mapGetters } from "vuex";
  210. export default {
  211. name: "workCompany",
  212. mixins: [mixinPage, resToken],
  213. components: {
  214. addEdit,
  215. },
  216. computed: {
  217. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  218. powers() {
  219. let tran =
  220. this.$store.getters.btnList.find(
  221. (item) => item.menu_route == "workCompany"
  222. ) || {};
  223. if (tran && tran.action && tran.action.length > 0) {
  224. return tran.action;
  225. } else {
  226. return [];
  227. }
  228. },
  229. },
  230. data() {
  231. return {
  232. select: "1", //选择
  233. input: "",
  234. supplierNo: [], //供应商
  235. stock_sn: "", //企业/仓库编码
  236. stock_name: "", //企业/仓库名称
  237. link: "", //联系电话/联系人
  238. loading: true,
  239. showModel: false,
  240. isDetail: false,
  241. modelId: 0,
  242. parmValue: {
  243. supplierNo: "", //供应商编码
  244. wsm_code: "", //仓库编码
  245. start: "", //新建起始时间
  246. end: "", //新建结束时间
  247. mobile: "", //手机号
  248. contactor: "", //联系人
  249. },
  250. tableData: [],
  251. passwordModel: false,
  252. passwordModelId: 0,
  253. isPasswordDetail: false,
  254. // 表格 - 数据
  255. tableData: [],
  256. // 表格 - 参数
  257. table: {
  258. stripe: true,
  259. border: true,
  260. _defaultHeader_: ["setcol"],
  261. },
  262. // 表格 - 分页
  263. pageInfo: {
  264. size: 15,
  265. curr: 1,
  266. total: 0,
  267. },
  268. // 表格 - 列参数
  269. columns: [
  270. {
  271. prop: "wsm_code",
  272. label: "编号",
  273. width: "170px",
  274. },
  275. {
  276. prop: "name",
  277. label: "仓库名称",
  278. },
  279. {
  280. prop: "supplierNo",
  281. label: "供应商编号",
  282. width: "140px",
  283. },
  284. {
  285. prop: "supplier_name",
  286. label: "供应商公司",
  287. "min-width": "140px",
  288. },
  289. {
  290. prop: "status",
  291. label: "状态",
  292. width: "60px",
  293. // sortable: true,
  294. _slot_: "status",
  295. },
  296. {
  297. prop: "contactor_name",
  298. label: "负责人",
  299. width: "70px",
  300. },
  301. {
  302. prop: "mobile",
  303. label: "负责人电话",
  304. width: "100px",
  305. },
  306. {
  307. prop: "addtime",
  308. label: "创建时间",
  309. width: "140px",
  310. },
  311. {
  312. prop: "",
  313. label: "操作",
  314. width: "140px",
  315. fixed: "right",
  316. _noset_: true,
  317. _slot_: "operation",
  318. },
  319. ],
  320. // 状态
  321. statusOptions: [
  322. { id: "0", label: "禁用" },
  323. { id: "1", label: "启用" },
  324. ],
  325. };
  326. },
  327. mounted() {
  328. this.searchList();
  329. },
  330. methods: {
  331. supplierChange(e) {
  332. if (e && e.id) {
  333. this.parmValue.supplierNo = e.code; //供应商编码
  334. } else {
  335. this.parmValue.supplierNo = "";
  336. }
  337. this.parmValue.page = 1;
  338. this.searchList();
  339. },
  340. stockChange(e) {
  341. if (e && e.id) {
  342. this.parmValue.wsm_code = e.code; //供应商编码
  343. } else {
  344. this.parmValue.wsm_code = "";
  345. }
  346. this.parmValue.page = 1;
  347. this.searchList();
  348. },
  349. addList(id) {
  350. window.vm.$router.push({
  351. path: "addStore",
  352. query: {
  353. id: id,
  354. },
  355. });
  356. },
  357. restSearch() {
  358. // 表格 - 分页
  359. this.pageInfo = {
  360. size: 15,
  361. curr: 1,
  362. total: 0,
  363. };
  364. this.supplierNo = [];
  365. this.input = "";
  366. this.select = "1";
  367. this.parmValue = {
  368. supplierNo: "", //供应商编码
  369. wsm_code: "", //仓库编码
  370. start: "", //新建起始时间
  371. end: "", //新建结束时间
  372. mobile: "", //手机号
  373. contactor: "", //联系人
  374. page: 1, // 页码
  375. size: 15, // 每页显示条数
  376. };
  377. this.searchList();
  378. },
  379. openModal(id, isDetail) {
  380. this.showModel = true;
  381. this.modelId = id;
  382. this.isDetail = isDetail;
  383. },
  384. async searchList() {
  385. this.loading = true;
  386. this.parmValue.wsm_code = this.select === "1" ? this.input : "";
  387. this.parmValue.contactor = this.select === "2" ? this.input : "";
  388. this.parmValue.mobile = this.select === "3" ? this.input : "";
  389. const res = await asyncRequest.list(this.parmValue);
  390. if (res && res.code === 0 && res.data) {
  391. this.tableData = res.data.list;
  392. this.pageInfo.total = Number(res.data.count);
  393. } else if (res && res.code >= 100 && res.code <= 104) {
  394. await this.logout();
  395. } else {
  396. this.tableData = [];
  397. this.pageInfo.total = 0;
  398. }
  399. this.loading = false;
  400. },
  401. async statusConfirm(id, status) {
  402. let str = status === "1" ? "禁用" : "启用";
  403. await this.$confirm("确定要改为" + str + "?", {
  404. confirmButtonText: "确定",
  405. cancelButtonText: "取消",
  406. type: "warning",
  407. })
  408. .then(async () => {
  409. this.loading = true;
  410. const model = {
  411. id: id,
  412. status: status === "1" ? "0" : "1",
  413. };
  414. const res = await asyncRequest.status(model);
  415. if (res && res.code === 0) {
  416. this.loading = false;
  417. this.$notify.success({
  418. title: "状态修改成功!",
  419. message: "",
  420. });
  421. await this.searchList();
  422. } else if (res && res.code >= 100 && res.code <= 104) {
  423. await this.logout();
  424. } else {
  425. this.$message.warning(res.message);
  426. }
  427. })
  428. .catch(() => {
  429. console.log("取消");
  430. });
  431. },
  432. async deleteById(id, status) {
  433. if (status === "1") {
  434. this.$message.warning("正在启用的仓库不能删除!");
  435. return;
  436. }
  437. await this.$confirm("确定要删除?", {
  438. confirmButtonText: "确定",
  439. cancelButtonText: "取消",
  440. type: "warning",
  441. })
  442. .then(async () => {
  443. const model = {
  444. id: id,
  445. // status: status === "1" ? "0" : "1",
  446. };
  447. const res = await asyncRequest.delete(model);
  448. if (res && res.code === 0) {
  449. this.$notify.success({
  450. title: "删除成功",
  451. message: "",
  452. });
  453. this.searchList();
  454. } else if (res && res.code >= 100 && res.code <= 104) {
  455. await this.logout();
  456. } else {
  457. this.$message.warning(res.message);
  458. }
  459. })
  460. .catch(() => {
  461. console.log("取消");
  462. });
  463. },
  464. },
  465. };
  466. </script>
  467. <style lang="scss" scoped>
  468. </style>