priceMaintenance.vue 10 KB

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