productModal.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <el-dialog
  3. center
  4. title="选择组合商品库存添加记录"
  5. :visible="_visible"
  6. :close-on-click-modal="false"
  7. :append-to-body="true"
  8. width="1024px"
  9. top="5vh"
  10. class="child-product"
  11. @close="handleClose"
  12. >
  13. <ex-table
  14. :table="table"
  15. v-loading="loading"
  16. :data="tableData"
  17. :columns="columns"
  18. :page="pageInfo"
  19. :size="size"
  20. @page-curr-change="handlePageChange"
  21. @page-size-change="handleSizeChange"
  22. @selection="selectionChange"
  23. @screen-reset="
  24. pageInfo.curr = 1;
  25. parmValue.page = 1;
  26. searchList();
  27. "
  28. @screen-submit="
  29. pageInfo.curr = 1;
  30. parmValue.page = 1;
  31. searchList();
  32. "
  33. >
  34. <template #table-header="{}">
  35. <div style="width: 100%">
  36. <el-row>
  37. <el-col :span="24">
  38. <el-col :span="6" style="width: 355px;">
  39. <period-date-picker
  40. :create_start="parmValue.create_start"
  41. :create_end="parmValue.create_end"
  42. :type="1"
  43. :width="'165px'"
  44. :size="searchSize"
  45. placeholder="创建"
  46. @timeReturned="timeReturned($event)"
  47. />
  48. </el-col>
  49. <el-col :span="3" style="width: 66px; float: right">
  50. <el-button
  51. type="primary"
  52. :size="searchSize"
  53. @click="searchList"
  54. style="float: right; margin-left: 5px"
  55. >刷新</el-button>
  56. </el-col>
  57. <el-col :span="4" style="width: 66px; float: right">
  58. <el-button type="warning" class="fr" :size="searchSize" @click="restSearch">重置</el-button>
  59. </el-col>
  60. </el-col>
  61. </el-row>
  62. <el-row style="margin-top: 10px">
  63. <el-col :span="6" style="width: 400px">
  64. <el-input
  65. v-model="value"
  66. :size="searchSize"
  67. placeholder="关键字"
  68. clearable
  69. :maxlength="40"
  70. @change="
  71. pageInfo.curr = 1;
  72. parmValue.page = 1;
  73. searchList();
  74. "
  75. >
  76. <template #prepend>
  77. <el-select
  78. v-model="parmValue.key"
  79. style="width:100px"
  80. @change="
  81. pageInfo.curr = 1;
  82. parmValue.page = 1;
  83. searchList();
  84. "
  85. >
  86. <el-option label="商品名称" value="spuCode" />
  87. <el-option label="商品编码" value="good_name" />
  88. </el-select>
  89. </template>
  90. <el-button
  91. slot="appcreate_end"
  92. icon="el-icon-search"
  93. @click="
  94. pageInfo.curr = 1;
  95. parmValue.page = 1;
  96. searchList();
  97. "
  98. ></el-button>
  99. </el-input>
  100. </el-col>
  101. </el-row>
  102. </div>
  103. </template>
  104. <template #status="{ scope }">
  105. <el-tag
  106. :size="tablebtnSize"
  107. :type="scope.row.status == '0' ? 'warning' : ''"
  108. v-text="
  109. (statusOptions.find((item) => item.id == scope.row.status) || {})
  110. .label || '--'
  111. "
  112. ></el-tag>
  113. </template>
  114. <template #order_source="{ scope }">
  115. <el-tag
  116. :size="tablebtnSize"
  117. v-text="
  118. (
  119. xs_order_source_options.find(
  120. (item) => item.id == scope.row.order_source
  121. ) || {}
  122. ).label || '--'
  123. "
  124. ></el-tag>
  125. </template>
  126. <template #catinfo="{ scope }">{{scope.row.catInfo.map(({name}) => name).join("-")}}</template>
  127. <template #specInfo="{ scope }">
  128. <span
  129. v-for="(si, sii) in scope.row.specInfo"
  130. :key="sii + si.spec_value_id"
  131. >{{ sii === 0 ? "" : "-" }}{{ si.spec_name }}[{{ si.spec_value }}]</span>
  132. </template>
  133. <template #order_type="{ scope }">
  134. <el-tag
  135. :size="tablebtnSize"
  136. v-text="
  137. (
  138. is_stock.find((item) => item.id == scope.row.is_stock) || {}
  139. ).name || '--'
  140. "
  141. ></el-tag>
  142. </template>
  143. </ex-table>
  144. <div style="display:flex;justify-content:flex-end">
  145. <el-button size="mini" type="primary" @click="onSave">保 存</el-button>
  146. </div>
  147. </el-dialog>
  148. </template>
  149. <script>
  150. import { has_account_list, isStockOptions } from "@/assets/js/statusList";
  151. import mixinPage from "@/mixins/elPaginationHandle";
  152. import resToken from "@/mixins/resToken";
  153. import asyncRequest from "@/apis/service/sellOut/combinedAdd";
  154. export default {
  155. name: "ProductListModal",
  156. mixins: [mixinPage, resToken],
  157. props: ["visible"],
  158. data() {
  159. return {
  160. options1: [
  161. { id: "0", name: "否" },
  162. { id: "1", name: "是" }
  163. ],
  164. options4: [
  165. { id: "0", name: "非库存品" },
  166. { id: "1", name: "库存品" }
  167. ],
  168. table: {
  169. stripe: true,
  170. border: true,
  171. _defaultHeader_: []
  172. },
  173. loading: false,
  174. selected: [],
  175. size: "mini",
  176. searchSize: "mini",
  177. tablebtnSize: "mini",
  178. sinput: "",
  179. select: "1",
  180. parmValue: {
  181. key: "spuCode",
  182. value: "",
  183. status: "",
  184. create_start: "",
  185. create_end: "",
  186. page: 1, // 页码
  187. size: 15 // 每页显示条数
  188. },
  189. has_account_list,
  190. isStockOptions,
  191. pageInfo: {
  192. size: 10,
  193. curr: 1,
  194. total: 0
  195. },
  196. isonlineoptions: [
  197. { id: "0", name: "未上线" },
  198. { id: "1", name: "已上线" }
  199. ],
  200. statusOptions: [
  201. { id: "1", label: "待审核" },
  202. { id: "2", label: "审核通过" },
  203. { id: "3", label: "审核驳回" }
  204. ],
  205. columns: [
  206. { type: "selection", fixed: "left", _noset_: true },
  207. {
  208. prop: "stockCode",
  209. label: "库存申请编码",
  210. fixed: "left",
  211. minWidth: "152px"
  212. },
  213. {
  214. prop: "spuCode",
  215. label: "商品编码",
  216. minWidth: "125px"
  217. },
  218. {
  219. label: "商品分类",
  220. minWidth: "125px",
  221. _slot_: "catinfo"
  222. },
  223. {
  224. prop: "good_name",
  225. label: "商品名称",
  226. minWidth: "125px"
  227. },
  228. {
  229. prop: "specInfo",
  230. label: "商品规格",
  231. minWidth: "125px",
  232. _slot_: "specInfo"
  233. },
  234. {
  235. prop: "status",
  236. _slot_: "status",
  237. label: "状态",
  238. width: "100px"
  239. },
  240. {
  241. prop: "apply_name",
  242. label: "申请人",
  243. width: "90px"
  244. },
  245. {
  246. prop: "createtime",
  247. label: "创建时间",
  248. width: "155px"
  249. }
  250. ],
  251. tableData: []
  252. };
  253. },
  254. computed: {
  255. _visible: {
  256. get() {
  257. return this.visible;
  258. },
  259. set(nV) {
  260. this.$emit("update:visible", nV);
  261. }
  262. }
  263. },
  264. watch: {
  265. visible(v) {
  266. if (!v) return;
  267. this.searchList();
  268. }
  269. },
  270. methods: {
  271. selectionChange(evt) {
  272. const { list } = evt;
  273. this.selected = list;
  274. },
  275. restSearch() {
  276. this.select = "2";
  277. this.sinput = "";
  278. this.supplierNo = [];
  279. this.brandid = [];
  280. // 表格 - 分页
  281. this.pageInfo = {
  282. size: 15,
  283. curr: 1,
  284. total: 0
  285. };
  286. this.parmValue = {
  287. page: 1, // 页码
  288. size: 15, // 每页显示条数
  289. start: "",
  290. end: "",
  291. status: "",
  292. good_name: "",
  293. company_name: "", // 创建人部门
  294. spucode: "",
  295. cat_id: [],
  296. brandid: "",
  297. good_type: "",
  298. isonline: "",
  299. companyNo: "",
  300. supplierNo: ""
  301. };
  302. this.searchList();
  303. },
  304. handleClose() {
  305. this.selected = [];
  306. this._visible = false;
  307. },
  308. proportionChange(proportion) {
  309. this.ruleForm.proportion = proportion;
  310. },
  311. onSave() {
  312. if (this.selected.length === 0 || this.selected.length > 1) {
  313. const message =
  314. this.selected.length === 0
  315. ? "请选择组合商品库存添加记录"
  316. : "只能选择一条组合商品库存记录";
  317. this.$message.warning(message);
  318. return;
  319. }
  320. const { id } = this.selected[0];
  321. this.$emit("selected", id);
  322. this._visible = false;
  323. },
  324. async searchList() {
  325. if (
  326. (this.parmValue.start !== "" && this.parmValue.end === "") ||
  327. (this.parmValue.start === "" && this.parmValue.end !== "")
  328. ) {
  329. this.$message.warning("时间区间不完整!");
  330. return;
  331. }
  332. this.loading = true;
  333. const { key, value, ...rest } = this.parmValue;
  334. const res = await asyncRequest.list({
  335. needRela: true,
  336. [key]: value,
  337. flag: "1",
  338. ...rest,
  339. status: "2"
  340. });
  341. if (res && res.code === 0 && res.data) {
  342. this.tableData = res.data.list;
  343. this.tableData.forEach(a => {
  344. a.cat_name = "";
  345. const list = a.cat_info || [];
  346. list.forEach((b, i) => {
  347. a.cat_name += i == 0 ? b.name : "/" + b.name;
  348. });
  349. });
  350. this.pageInfo.total = Number(res.data.count);
  351. } else if (res && res.code >= 100 && res.code <= 104) {
  352. await this.logout();
  353. } else {
  354. this.tableData = [];
  355. this.pageInfo.total = 0;
  356. }
  357. this.loading = false;
  358. }
  359. }
  360. };
  361. </script>
  362. <style lang="scss" scoped>
  363. .child-product {
  364. /deep/ .el-pagination {
  365. float: left !important;
  366. }
  367. }
  368. </style>