index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="terrace pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers.some((i) => i == '001')"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 10px 80px">
  27. <el-col :span="4" style="width: 293px">
  28. <period-date-picker
  29. :type="1"
  30. :width="'135px'"
  31. :size="searchSize"
  32. :start="parmValue.start"
  33. :end="parmValue.end"
  34. @timeReturned="handleTime"
  35. />
  36. </el-col>
  37. <el-col :span="4" style="width: 380px; padding: 0 0 0 10px">
  38. <el-select v-model="parmValue.status" size="mini" clearable
  39. @change="pageInfo.curr = 1; parmValue.page = 1; searchList();"
  40. >
  41. <el-option label="未转单" value="1"></el-option>
  42. <el-option label="已转单" value="2"></el-option>
  43. </el-select>
  44. </el-col>
  45. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  46. <el-button type="primary" :size="searchSize" @click="searchList"
  47. >刷新</el-button
  48. >
  49. </el-col>
  50. <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
  51. <el-button type="warning" :size="searchSize" @click="restSearch"
  52. >重置</el-button
  53. >
  54. </el-col>
  55. <!-- <el-col
  56. :span="3"
  57. class="fr"
  58. style="width: 66px; padding: 0 0 0 10px"
  59. v-if="powers.includes('003') && !isSupertube"
  60. >
  61. <el-button type="success" :size="searchSize" @click="openModal({}, '003')"
  62. >添加</el-button
  63. >
  64. </el-col> -->
  65. </el-row>
  66. <el-row>
  67. <el-col :span="6" style="width: 373px">
  68. <search-customer
  69. size="mini"
  70. :value="parmValue.customer"
  71. :names="customerName"
  72. @searchChange="handleCustomerChange"
  73. placeholder="客户公司"
  74. />
  75. </el-col>
  76. <el-col :span="3" class="fr" style="width: 116px; padding: 0 0 0 10px" v-if="powers.includes('013') && !isSupertube">
  77. <el-button
  78. class="fr"
  79. type="primary"
  80. :size="searchSize"
  81. @click="downloadTemplate"
  82. >
  83. 下载导入模板
  84. </el-button>
  85. </el-col>
  86. <el-col :span="3" class="fr" style="width: 116px; padding: 0 0 0 10px" v-if="powers.includes('086') && !isSupertube">
  87. <el-button
  88. type="primary"
  89. class="fr"
  90. :size="searchSize"
  91. @click="() => (templateModalVisible = true)"
  92. >
  93. 导入订单数据
  94. </el-button>
  95. </el-col>
  96. </el-row>
  97. </div>
  98. </template>
  99. <template #status="{ scope }">
  100. <el-tag
  101. :size="tablebtnSize"
  102. :type="scope.row.status + '' == '1' ? 'warning' : ''"
  103. v-text="scope.row.status + '' === '1' ? '未转单' : '已转单'"
  104. ></el-tag>
  105. </template>
  106. <template #order_type="{ scope }">
  107. <el-tag
  108. :size="tablebtnSize"
  109. v-text="
  110. (xs_order_type_options.find((item) => item.id == scope.row.order_type) || {})
  111. .label || '--'
  112. "
  113. ></el-tag>
  114. </template>
  115. <template #order_source="{ scope }">
  116. <el-tag
  117. :size="tablebtnSize"
  118. v-text="
  119. (
  120. xs_order_source_options.find((item) => item.id == scope.row.order_source) ||
  121. {}
  122. ).label || '--'
  123. "
  124. ></el-tag>
  125. </template>
  126. <template #operation="{ scope }">
  127. <el-tooltip
  128. v-if="(powers.some((i) => i == '007') && !isSupertube) || isSupertube"
  129. effect="dark"
  130. content="详情"
  131. placement="top"
  132. >
  133. <i class="el-icon-view tb-icon" @click="openModal(scope.row, '007')"></i>
  134. </el-tooltip>
  135. <el-tooltip
  136. v-if="powers.some((i) => i == '005') && !isSupertube"
  137. effect="dark"
  138. content="修改"
  139. placement="top"
  140. >
  141. <i class="el-icon-edit tb-icon" @click="openModal(scope.row, '005')"></i>
  142. </el-tooltip>
  143. </template>
  144. </ex-table>
  145. <no-auth v-else></no-auth>
  146. <import-template-modal :visible.sync="templateModalVisible" @refresh="() => searchList()" />
  147. <!-- 弹窗 新增/修改 -->
  148. <add-edit
  149. :id="modelId"
  150. :show-model="showModel"
  151. :sitem="sitem"
  152. @refresh="searchList"
  153. @cancel="showModel = false"
  154. />
  155. </div>
  156. </template>
  157. <script>
  158. import asyncRequest from "@/apis/service/netOrderEntry/prestoreRecordingOrders";
  159. import { xs_order_type_options, xs_order_source_options } from "@/assets/js/statusList";
  160. import { statusList } from "@/assets/js/statusList";
  161. import mixinPage from "@/mixins/elPaginationHandle";
  162. import roleLevel from "@/assets/js/roleLevel";
  163. import resToken from "@/mixins/resToken";
  164. import { mapGetters } from "vuex";
  165. import addEdit from "./addEdit";
  166. import companyHelper from "@/mixins/companyHelper";
  167. import { utils, writeFile } from "xlsx";
  168. import importTemplateModal from "./importTemplateModal.vue";
  169. import { template } from "./template";
  170. export default {
  171. name: "netOrderEnter",
  172. mixins: [mixinPage, resToken, companyHelper],
  173. components: {
  174. addEdit,
  175. importTemplateModal,
  176. },
  177. computed: {
  178. //组件SIZE设置
  179. ...mapGetters(["tablebtnSize", "searchSize", "size", "isSupertube"]),
  180. powers() {
  181. const { btnList } = this.$store.getters;
  182. const tran = btnList.find((i) => i.menu_route == "prestoreRecordingOrders") || {};
  183. const { action } = tran ?? {};
  184. return action ?? [];
  185. },
  186. },
  187. data() {
  188. const mapSelectValue2Query = {
  189. orderCode: "销售订单编号",
  190. cgdNo: "采购单编号",
  191. };
  192. return {
  193. templateModalVisible: false,
  194. xs_order_type_options,
  195. xs_order_source_options,
  196. statusList: statusList,
  197. roleLevel: roleLevel,
  198. loading: true,
  199. showModel: false,
  200. modelId: "000",
  201. select: "orderCode",
  202. sitem: {},
  203. customerName: "",
  204. mapSelectValue2Query,
  205. value: "",
  206. parmValue: {
  207. page: 1, // 页码
  208. size: 15, // 每页显示条数
  209. start: "",
  210. end: "",
  211. customer: "",
  212. status:''
  213. },
  214. // 表格 - 数据
  215. tableData: [],
  216. // 表格 - 参数
  217. table: {
  218. stripe: true,
  219. border: true,
  220. _defaultHeader_: ["setcol"],
  221. },
  222. statusOptions: [
  223. { id: "0", label: "待发货" },
  224. { id: "1", label: "待发货完成" },
  225. { id: "2", label: "发货已完成" },
  226. { id: "3", label: "订单已取消" },
  227. ],
  228. // 表格 - 分页
  229. pageInfo: {
  230. size: 15,
  231. curr: 1,
  232. total: 0,
  233. },
  234. columns: [
  235. {
  236. prop: "interNo",
  237. label: "录单编号",
  238. width: "175px",
  239. },
  240. {
  241. prop: "orderCode",
  242. label: "订单编号",
  243. width: "175px",
  244. },
  245. {
  246. prop: "good_name",
  247. label: "商品名称",
  248. width: "150",
  249. },
  250. {
  251. prop: "good_num",
  252. label: "商品数量",
  253. },
  254. {
  255. prop: "sale_price",
  256. label: "销售单价",
  257. },
  258. {
  259. prop: "sale_total",
  260. label: "销售总价",
  261. },
  262. {
  263. prop:'status',
  264. label:'状态',
  265. _slot_:'status'
  266. },
  267. {
  268. prop: "supplierNo",
  269. label: "供应商公司编号",
  270. width: "155px",
  271. },
  272. {
  273. prop: "supplierName",
  274. label: "供应商公司名称",
  275. width: "125px",
  276. },
  277. {
  278. prop: "customerNo",
  279. label: "购买方公司编号",
  280. width: "155px",
  281. },
  282. {
  283. prop: "customerName",
  284. label: "购买方公司名称",
  285. width: "125px",
  286. },
  287. {
  288. prop: "companyNo",
  289. label: "销售方公司编码",
  290. width: "125px",
  291. },
  292. {
  293. prop: "companyName",
  294. label: "销售方公司名称",
  295. width: "125px",
  296. },
  297. // {
  298. // prop: "company_name",
  299. // label: "订单创建人部门",
  300. // minWidth: "120px",
  301. // },
  302. {
  303. prop: "apply_name",
  304. label: "创建人",
  305. width: "85px",
  306. },
  307. // {
  308. // prop: "cgder",
  309. // label: "供应商负责人",
  310. // width: "95",
  311. // },
  312. // {
  313. // prop: "good_creater",
  314. // label: "商品创建人",
  315. // width: "85px",
  316. // },
  317. {
  318. prop: "addtime",
  319. label: "创建时间",
  320. width: "145px",
  321. },
  322. {
  323. prop: "",
  324. label: "操作",
  325. fixed: "right",
  326. _noset_: true,
  327. width: "80px",
  328. _slot_: "operation",
  329. },
  330. ],
  331. };
  332. },
  333. mounted() {
  334. this.searchList();
  335. },
  336. methods: {
  337. downloadTemplate() {
  338. const workBook = new utils.book_new();
  339. const workSheet = new utils.json_to_sheet(template);
  340. utils.book_append_sheet(workBook, workSheet, "sheet");
  341. writeFile(workBook, "采销订单补录.xlsx", {
  342. bookType: "xlsx",
  343. });
  344. },
  345. restSearch() {
  346. // 表格 - 分页
  347. this.pageInfo = {
  348. size: 15,
  349. curr: 1,
  350. total: 0,
  351. };
  352. this.parmValue = {
  353. page: 1, // 页码
  354. size: 15, // 每页显示条数
  355. start: "",
  356. end: "",
  357. customer: "",
  358. supplierNo: "",
  359. };
  360. this.value = "";
  361. this.searchList();
  362. },
  363. // 新建/编辑/详情
  364. openModal(row, type) {
  365. if (type === "003" && !this.currentCompany) {
  366. this.$message.warning("请选择一家业务公司");
  367. return;
  368. }
  369. this.sitem = row;
  370. this.modelId = type;
  371. this.showModel = true;
  372. },
  373. // 时间
  374. async handleTime(e) {
  375. this.parmValue.start = e.startTime || "";
  376. this.parmValue.end = e.endTime || "";
  377. if (
  378. (this.parmValue.start !== "" && this.parmValue.end !== "") ||
  379. (this.parmValue.start === "" && this.parmValue.end === "")
  380. ) {
  381. this.pageInfo.curr = 1;
  382. this.parmValue.page = 1;
  383. await this.searchList();
  384. }
  385. },
  386. handleCustomerChange(e) {
  387. this.parmValue.customer = e.code ? [e.code] : "";
  388. this.customerName = e.label;
  389. this.searchList();
  390. },
  391. handleSupplierChange(e) {
  392. this.parmValue.supplierNo = e.code ? [e.code] : "";
  393. this.searchList();
  394. },
  395. /**
  396. * 启用/禁用
  397. * @param {String} id id
  398. * @param {String} status 0-禁用 1-启用
  399. */
  400. async changeStatus(id, status) {
  401. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  402. confirmButtonText: "确定",
  403. cancelButtonText: "取消",
  404. type: "warning",
  405. })
  406. .then(async () => {
  407. this.loading = true;
  408. const model = {
  409. id: id,
  410. status: status === "1" ? "0" : "1",
  411. };
  412. const res = await asyncRequest.status(model);
  413. if (res && res.code === 0) {
  414. this.loading = false;
  415. this.$notify.success({
  416. title: "状态修改成功!",
  417. message: "",
  418. });
  419. await this.searchList();
  420. } else if (res && res.code >= 100 && res.code <= 104) {
  421. await this.logout();
  422. } else {
  423. this.loading = false;
  424. this.$message.warning(res.message);
  425. }
  426. })
  427. .catch(() => {
  428. console.log("取消");
  429. });
  430. },
  431. // 刷新表格
  432. async searchList() {
  433. const vm = this;
  434. if (
  435. (vm.parmValue.start !== "" && vm.parmValue.end === "") ||
  436. (vm.parmValue.start == "" && vm.parmValue.end != "")
  437. ) {
  438. vm.$message.warning("开始时间和结束时间不能为空");
  439. return;
  440. }
  441. vm.loading = true;
  442. const res = await asyncRequest.list({
  443. ...vm.parmValue,
  444. ...(vm.value ? { [vm.select]: vm.value } : {}),
  445. ...(vm.parmValue.customer ? { customer: vm.parmValue.customer[0] }: {}),
  446. ...(vm.parmValue.supplierNo ? { supplierNo: vm.parmValue.supplierNo[0] } : {}),
  447. });
  448. if (res && res.code === 0 && res.data) {
  449. vm.tableData = res.data.list;
  450. vm.pageInfo.total = Number(res.data.count);
  451. } else if (res && res.code >= 100 && res.code <= 104) {
  452. await vm.logout();
  453. } else {
  454. vm.tableData = [];
  455. vm.pageInfo.total = 0;
  456. }
  457. vm.loading = false;
  458. },
  459. },
  460. };
  461. </script>
  462. <style lang="scss" scoped></style>