priceMaintenance.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <test :form-config="btnForm"> </test>
  5. <query
  6. :selectConfig="selectConfig"
  7. :req="queryParams"
  8. :isShowMore="true"
  9. @handleQuery="handleQuery"
  10. @handleMore="
  11. () => {
  12. queryDialog = true;
  13. }
  14. "
  15. ></query>
  16. <el-table :data="tableList" v-loading="loading">
  17. <el-table-column
  18. :label="$t('product_material.supply.supplyType')"
  19. align="center"
  20. prop="applicationName"
  21. />
  22. <el-table-column
  23. :label="$t('product_material.supply.supplyName')"
  24. align="center"
  25. prop="applicationName"
  26. />
  27. <el-table-column
  28. :label="$t('product_material.product.productType')"
  29. align="center"
  30. prop="applicationName"
  31. />
  32. <el-table-column
  33. :label="$t('product_material.product.productCode')"
  34. align="center"
  35. prop="applicationName"
  36. />
  37. <el-table-column
  38. :label="$t('product_material.product.productName')"
  39. align="center"
  40. prop="applicationName"
  41. />
  42. <el-table-column
  43. :label="$t('product_material.supply.priceMaintenance.supplyPrice')"
  44. align="center"
  45. prop="applicationName"
  46. />
  47. <el-table-column :label="$t('operation')" align="center" width="120">
  48. <template slot-scope="scope">
  49. <el-button type="text" @click="handleEdit(scope.row)"
  50. >{{ $t("edit") }}
  51. </el-button>
  52. <el-button type="text" @click="handleDelete(scope.row)"
  53. >{{ $t("delete") }}
  54. </el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <pagination
  59. v-show="total > 0"
  60. :total="total"
  61. :page.sync="queryParams.pageNum"
  62. :limit.sync="queryParams.pageSize"
  63. @pagination="getList"
  64. />
  65. <el-dialog
  66. :title="
  67. titleText === 'add'
  68. ? $t('product_material.supply.priceMaintenance.supplyPriceAdd')
  69. : $t('product_material.supply.priceMaintenance.supplyPriceEdit')
  70. "
  71. :visible.sync="open"
  72. v-if="open"
  73. width="50%"
  74. top="60px"
  75. >
  76. <add-supply-price
  77. :form="form"
  78. :supplySelectList="supplySelectList"
  79. @submit="handleSubmit"
  80. @cancel="handleCancel"
  81. ref="addSupplyPrice"
  82. ></add-supply-price>
  83. </el-dialog>
  84. <el-dialog
  85. :title="$t('seniorQuery')"
  86. :visible.sync="queryDialog"
  87. v-if="queryDialog"
  88. width="30%"
  89. >
  90. <el-form
  91. label-position="top"
  92. :model="queryParams"
  93. ref="queryForm"
  94. label-width="100px"
  95. >
  96. <el-row>
  97. <el-col :span="12">
  98. <el-form-item
  99. :label="$t('product_material.supply.supplyName')"
  100. prop="type"
  101. >
  102. <el-select
  103. v-model="queryParams.type"
  104. :placeholder="$t('pleaseSelect')"
  105. style="width: 100%"
  106. >
  107. <el-option
  108. v-for="item in options"
  109. :key="item.value"
  110. :label="item.label"
  111. :value="item.value"
  112. >
  113. </el-option>
  114. </el-select>
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. <el-row>
  119. <el-col :span="12">
  120. <el-form-item
  121. :label="$t('product_material.supply.priceMaintenance.goodCode')"
  122. prop="type"
  123. >
  124. <el-select
  125. v-model="queryParams.type"
  126. :placeholder="$t('pleaseSelect')"
  127. style="width: 100%"
  128. >
  129. <el-option
  130. v-for="item in options"
  131. :key="item.value"
  132. :label="item.label"
  133. :value="item.value"
  134. >
  135. </el-option>
  136. </el-select>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. <el-form-item
  141. :label="$t('product_material.supply.priceMaintenance.goodName')"
  142. prop="name"
  143. >
  144. <el-input
  145. v-model="queryParams.name"
  146. :placeholder="$t('pleaseInput')"
  147. ></el-input>
  148. </el-form-item>
  149. <el-row>
  150. <el-col :span="12">
  151. <el-form-item
  152. :label="$t('product_material.supply.priceMaintenance.goodType')"
  153. prop="code"
  154. >
  155. <el-select
  156. v-model="queryParams.type"
  157. :placeholder="$t('pleaseSelect')"
  158. style="width: 100%"
  159. >
  160. <el-option
  161. v-for="item in options"
  162. :key="item.value"
  163. :label="item.label"
  164. :value="item.value"
  165. >
  166. </el-option>
  167. </el-select>
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. <div style="text-align: center">
  172. <el-button size="small" @click="queryDialog = false"
  173. >{{ $t("cancel") }}
  174. </el-button>
  175. <el-button type="primary" size="small" @click="handleQuery">
  176. {{ $t("submit") }}</el-button
  177. >
  178. </div>
  179. </el-form>
  180. </el-dialog>
  181. </el-card>
  182. </div>
  183. </template>
  184. <script>
  185. import test from "@/components/form-test/index.vue";
  186. import query from "@/components/query/index.vue";
  187. import { supplySelect } from "@/api/product-material/supply/index.js";
  188. import * as API from "@/api/product-material/supply/priceMaintenance.js";
  189. import addSupplyPrice from "./addSupplyPrice.vue";
  190. export default {
  191. components: {
  192. test,
  193. query,
  194. addSupplyPrice,
  195. },
  196. data() {
  197. return {
  198. supplySelectList: [],
  199. productTypeList: [],
  200. queryParams: {
  201. pageNum: 1,
  202. pageSize: 10,
  203. keyword: "",
  204. supplierId: "",
  205. materialId: "",
  206. supplierName: "",
  207. materialName: "",
  208. materialCode: "",
  209. materialType: "",
  210. },
  211. btnForm: {
  212. otherButton: {
  213. list: [
  214. {
  215. name: this.$t(
  216. "product_material.supply.priceMaintenance.supplyPriceAdd"
  217. ),
  218. methodsText: "add",
  219. type: "primary",
  220. add: () => {
  221. this.supplyPriceAdd();
  222. },
  223. },
  224. // {
  225. // name: this.$t("product_material.supply.priceMaintenance.back"),
  226. // methodsText: "back",
  227. // type: "defualt",
  228. // back: () => {
  229. // this.back();
  230. // },
  231. // },
  232. ],
  233. },
  234. },
  235. selectConfig: [
  236. {
  237. label: this.$t("product_material.product.productType"),
  238. prop: "type",
  239. data: [],
  240. },
  241. {
  242. label: this.$t("product_material.supply.supplyType"),
  243. prop: "type",
  244. data: [],
  245. },
  246. ],
  247. queryDialog: false,
  248. tableList: [],
  249. loading: false,
  250. total: null,
  251. open: false,
  252. titleText: "add",
  253. form: {
  254. supplierId: "",
  255. materialId: "",
  256. price: "",
  257. id: "",
  258. },
  259. };
  260. },
  261. created() {
  262. const businessDictData = JSON.parse(
  263. window.localStorage.getItem("businessDict")
  264. );
  265. this.productTypeList = businessDictData.find(
  266. (item) => item.code === "productType"
  267. ).children;
  268. this.selectConfig[0].data = this.productTypeList.map((item) => ({
  269. label: item.dictValue,
  270. value: item.dictKey,
  271. }));
  272. this.supplyTypeList = businessDictData.find(
  273. (item) => item.code === "supplyType"
  274. ).children;
  275. this.selectConfig[1].data = this.supplyTypeList.map((item) => ({
  276. label: item.dictValue,
  277. value: item.dictKey,
  278. }));
  279. supplySelect({ name: "", type: "", code: "" }).then((res) => {
  280. this.supplySelectList = res.data.data;
  281. });
  282. this.getList();
  283. },
  284. methods: {
  285. back() {
  286. this.$router.push({
  287. path: "/product-material/supply/index",
  288. });
  289. },
  290. getList() {
  291. this.loading = true;
  292. API.supplyPriceList(this.queryParams).then(
  293. (res) => {
  294. this.tableList = res.data.data.records;
  295. this.total = res.data.data.total;
  296. this.loading = false;
  297. },
  298. (err) => {
  299. console.log("supplyPriceList: " + err);
  300. this.loading = false;
  301. }
  302. );
  303. },
  304. handleQuery() {
  305. this.getList();
  306. },
  307. supplyPriceAdd() {
  308. this.form = {
  309. supplierId: "",
  310. materialId: "",
  311. price: "",
  312. id: "",
  313. };
  314. this.titleText = "add";
  315. this.open = true;
  316. },
  317. handleCancel() {
  318. this.form = {
  319. supplierId: "",
  320. materialId: "",
  321. price: "",
  322. id: "",
  323. };
  324. this.open = false;
  325. },
  326. handleEdit(row) {
  327. this.titleText = "edit";
  328. this.form = row;
  329. this.open = true;
  330. },
  331. handleSubmit() {
  332. if (!this.form.id) {
  333. API.supplyPriceAdd(this.form).then(
  334. () => {
  335. this.msgSuccess(this.$t("addSuccess"));
  336. this.$refs.addSupplyPrice.loading = false;
  337. this.open = false;
  338. this.getList();
  339. },
  340. (err) => {
  341. console.log("supplyPriceAdd: " + err);
  342. this.$refs.addSupplyPrice.loading = false;
  343. }
  344. );
  345. } else {
  346. API.supplyPriceEdit(this.form).then(
  347. () => {
  348. this.msgSuccess(this.$t("editSuccess"));
  349. this.open = false;
  350. this.$refs.addSupplyPrice.loading = false;
  351. this.getList();
  352. },
  353. (err) => {
  354. console.log("supplyPriceEdit: " + err);
  355. this.$refs.addSupplyPrice.loading = false;
  356. }
  357. );
  358. }
  359. },
  360. handleDelete(row) {
  361. this.$confirm(this.$t("askDeleteData"), {
  362. confirmButtonText: this.$t("submitText"),
  363. cancelButtonText: this.$t("cancelText"),
  364. type: "warning",
  365. }).then(() => {
  366. API.supplyPriceDel({ id: row.id }).then(() => {
  367. this.msgSuccess(this.$t("deleteSuccess"));
  368. this.getList();
  369. });
  370. });
  371. },
  372. },
  373. };
  374. </script>
  375. <style lang="scss" scoped>
  376. .box-card {
  377. height: calc(100vh - 110px);
  378. overflow-y: auto;
  379. }
  380. </style>