index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <div class="video-setting">
  3. <el-row :gutter="8">
  4. <el-col :span="6">
  5. <tree @treeClick="reload"></tree>
  6. </el-col>
  7. <el-col :span="18" class="right">
  8. <el-card class="top">
  9. <el-button type="primary" size="small" @click="materialAdd">{{
  10. $t("product_material.material.materialAdd")
  11. }}</el-button>
  12. </el-card>
  13. <el-card class="bottom">
  14. <query
  15. :selectConfig="selectConfig"
  16. :req="req"
  17. :isShowMore="true"
  18. @handleQuery="handleQuery"
  19. @handleMore="
  20. () => {
  21. queryDialog = true;
  22. }
  23. "
  24. ></query>
  25. <el-table :data="tableList" v-loading="loading">
  26. <el-table-column
  27. :label="$t('product_material.material.materialType')"
  28. align="center"
  29. />
  30. <el-table-column
  31. :label="$t('product_material.material.materialCode')"
  32. align="center"
  33. />
  34. <el-table-column
  35. :label="$t('product_material.material.materialName')"
  36. align="center"
  37. prop="materialName"
  38. />
  39. <el-table-column
  40. :label="$t('product_material.material.materialUnit')"
  41. align="center"
  42. prop="materialUnit"
  43. />
  44. <el-table-column
  45. :label="$t('product_material.material.deptId')"
  46. align="center"
  47. prop="deptId"
  48. />
  49. <el-table-column
  50. :label="$t('product_material.material.description')"
  51. align="center"
  52. prop="description"
  53. />
  54. <el-table-column
  55. :label="$t('operation')"
  56. align="center"
  57. width="120"
  58. >
  59. <template slot-scope="scope">
  60. <el-button type="text" @click="handleEdit(scope.row)"
  61. >{{ $t("edit") }}
  62. </el-button>
  63. <el-button type="text" @click="handleDelete(scope.row)"
  64. >{{ $t("delete") }}
  65. </el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-dialog
  70. :title="
  71. titleText === 'add'
  72. ? $t('product_material.material.materialAdd')
  73. : $t('product_material.material.materialEdit')
  74. "
  75. :visible.sync="open"
  76. v-if="open"
  77. width="50%"
  78. top="60px"
  79. >
  80. <add-material
  81. :form="form"
  82. @submit="handleSubmit"
  83. @cancel="handleCancel"
  84. ref="addMaterial"
  85. ></add-material>
  86. </el-dialog>
  87. <el-dialog
  88. :title="$t('seniorQuery')"
  89. v-if="queryDialog"
  90. :visible.sync="queryDialog"
  91. width="50%"
  92. top="60px"
  93. >
  94. <div class="search-box">
  95. <el-form :form="req" label-position="top" label-width="100px">
  96. <el-row>
  97. <el-col :span="6">
  98. <el-form-item
  99. :label="$t('product_material.material.materialType')"
  100. >
  101. <el-select
  102. v-model="req.type"
  103. :placeholder="$t('pleaseSelect')"
  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="6">
  119. <el-form-item
  120. :label="$t('product_material.material.deptId')"
  121. >
  122. <el-select
  123. v-model="req.deptId"
  124. :placeholder="$t('pleaseSelect')"
  125. style="width: 100%"
  126. >
  127. <el-option
  128. v-for="item in options"
  129. :key="item.value"
  130. :label="item.label"
  131. :value="item.value"
  132. >
  133. </el-option>
  134. </el-select>
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. <el-row>
  139. <el-col :span="6">
  140. <el-form-item
  141. :label="$t('product_material.material.materialCode')"
  142. >
  143. <el-input
  144. v-model="req.code"
  145. :placeholder="$t('pleaseInput')"
  146. ></el-input>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. <el-form-item
  151. :label="$t('product_material.material.materialName')"
  152. >
  153. <el-input
  154. v-model="req.name"
  155. :placeholder="$t('pleaseInput')"
  156. ></el-input>
  157. </el-form-item>
  158. </el-form>
  159. </div>
  160. <div style="text-align: center; margin-top: 15px">
  161. <el-button size="small" @click="handleReset"
  162. >{{ $t("reset") }}
  163. </el-button>
  164. <el-button type="primary" size="small" @click="handleQuery">
  165. {{ $t("submit") }}</el-button
  166. >
  167. </div>
  168. </el-dialog>
  169. </el-card>
  170. </el-col>
  171. </el-row>
  172. </div>
  173. </template>
  174. <script>
  175. import tree from "./tree.vue";
  176. import byTable from "@/components/by-table/index.js";
  177. import test from "@/components/form-test/index.vue";
  178. import query from "@/components/query/index.vue";
  179. import addMaterial from "./addMaterial.vue";
  180. import * as API from "@/api/product-material/material/index.js";
  181. export default {
  182. name: "material",
  183. components: {
  184. tree,
  185. byTable,
  186. test,
  187. query,
  188. addMaterial,
  189. },
  190. data() {
  191. return {
  192. req: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. keyword: "",
  196. classifyId: "",
  197. },
  198. tableList: [],
  199. total: 0,
  200. loading: false,
  201. selectConfig: [
  202. {
  203. label: this.$t("product_material.material.materialType"),
  204. prop: "type",
  205. data: [
  206. { label: "原料", value: 1 },
  207. { label: "辅料", value: 2 },
  208. { label: "配件", value: 3 },
  209. { label: "包材", value: 4 },
  210. { label: "其他", value: 5 },
  211. ],
  212. },
  213. ],
  214. open: false,
  215. titleText: "",
  216. form: {
  217. classifyId: "",
  218. type: "",
  219. code: "",
  220. name: "",
  221. unit: "",
  222. introduce: "",
  223. deptId: "",
  224. },
  225. queryDialog: false,
  226. };
  227. },
  228. created() {
  229. API.materialTree({
  230. type: "2",
  231. name: "",
  232. }).then(
  233. (res) => {
  234. this.dialogForm.classifyId.data = res.data.data;
  235. this.loading = false;
  236. },
  237. (err) => {
  238. console.log("materialTree: " + err);
  239. this.loading = false;
  240. }
  241. );
  242. this.getList();
  243. },
  244. methods: {
  245. handleReset() {
  246. this.req = {
  247. pageNum: 1,
  248. pageSize: 10,
  249. keyword: "",
  250. classifyId: "",
  251. deptId: "",
  252. };
  253. },
  254. handleQuery() {
  255. console.log(this.req, "sss");
  256. this.getList();
  257. },
  258. getList() {
  259. this.loading = true;
  260. API.materialList(this.req).then(
  261. (res) => {
  262. this.tableList = res.data.data;
  263. this.loading = false;
  264. },
  265. (err) => {
  266. console.log("materialList: " + err);
  267. this.loading = false;
  268. }
  269. );
  270. API.materialCount(this.req).then(
  271. (res) => {
  272. this.total = res.data.data.count;
  273. },
  274. (err) => {
  275. console.log("materialCount: " + err);
  276. }
  277. );
  278. },
  279. materialAdd() {
  280. this.titleText = "add";
  281. this.open = true;
  282. },
  283. handleEdit(row) {
  284. this.titleText = "edit";
  285. this.dialogParams = row;
  286. this.open = true;
  287. },
  288. handleDelete(row) {
  289. this.$confirm(this.$t("askDeleteData"), {
  290. confirmButtonText: this.$t("submitText"),
  291. cancelButtonText: this.$t("cancelText"),
  292. type: "warning",
  293. })
  294. .then(() => {
  295. API.materialDel({ id: row.id, type: "1" }).then(() => {
  296. this.msgSuccess(this.$t("deleteSuccess"));
  297. this.getList();
  298. });
  299. })
  300. .catch((err) => {
  301. console.log(err);
  302. });
  303. },
  304. reload(row) {
  305. this.req.pageNum = 1;
  306. this.req.classifyId = row.id;
  307. this.getList();
  308. },
  309. handleCancel() {
  310. this.form = {
  311. classifyId: "",
  312. type: "",
  313. code: "",
  314. name: "",
  315. unit: "",
  316. introduce: "",
  317. deptId: "",
  318. };
  319. this.open = false;
  320. },
  321. handleSubmit() {
  322. if (this.form.id) {
  323. API.materialAdd(this.form).then(
  324. () => {
  325. this.msgSuccess(this.$t("addSuccess"));
  326. this.$refs.addProduct.loading = false;
  327. this.open = false;
  328. this.getList();
  329. },
  330. (err) => {
  331. console.log("materialAdd: " + err);
  332. this.$refs.addProduct.loading = false;
  333. }
  334. );
  335. } else {
  336. API.materialEdit(this.form).then(
  337. () => {
  338. this.msgSuccess(this.$t("editSuccess"));
  339. this.open = false;
  340. this.$refs.addProduct.loading = false;
  341. this.getList();
  342. },
  343. (err) => {
  344. console.log("materialEdit: " + err);
  345. this.$refs.addProduct.loading = false;
  346. }
  347. );
  348. }
  349. },
  350. },
  351. };
  352. </script>
  353. <style lang="scss" scoped>
  354. .search-box {
  355. height: calc(100vh - 280px);
  356. overflow: auto;
  357. box-sizing: border-box;
  358. padding: 10px;
  359. }
  360. .right {
  361. height: calc(100vh - 110px);
  362. overflow-y: auto;
  363. display: flex;
  364. flex-direction: column;
  365. .top {
  366. // padding: 10px;
  367. margin-bottom: 8px;
  368. }
  369. .bottom {
  370. flex: 1;
  371. }
  372. }
  373. </style>