PropertyForm.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="100px"
  10. @submit.native.prevent
  11. >
  12. <el-form-item :label="$t('mes.standard.propertyName')" prop="propertyName">
  13. <el-input
  14. disabled
  15. v-model="queryParams.propertyName"
  16. :placeholder="$t('mes.standard.propertyNamePlaceholder')"
  17. clearable
  18. @keyup.enter.native="handleQuery"
  19. />
  20. </el-form-item>
  21. <el-form-item :label="$t('mes.standardPropertyForm.valueName')" prop="valueName">
  22. <el-input
  23. v-model="queryParams.valueName"
  24. :placeholder="$t('mes.standardPropertyForm.valueNamePlaceholder')"
  25. clearable
  26. @keyup.enter.native="handleQuery"
  27. />
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button
  31. v-no-more-click
  32. type="primary"
  33. icon="el-icon-search"
  34. size="mini"
  35. @click="handleQuery"
  36. >{{ $t('common.search') }}
  37. </el-button
  38. >
  39. <el-button
  40. v-no-more-click
  41. icon="el-icon-refresh"
  42. size="mini"
  43. @click="resetQuery"
  44. >{{ $t('common.reset') }}
  45. </el-button
  46. >
  47. <el-button
  48. v-no-more-click
  49. type="warning"
  50. icon="el-icon-close"
  51. size="mini"
  52. @click="goBack"
  53. >{{ $t('common.back') }}
  54. </el-button
  55. >
  56. </el-form-item>
  57. </el-form>
  58. <el-row :gutter="10" class="mb8">
  59. <el-col :span="1.5">
  60. <el-button
  61. v-no-more-click
  62. type="primary"
  63. plain
  64. icon="el-icon-plus"
  65. size="mini"
  66. @click="handleAdd"
  67. v-hasPermi="['iscs:propvalue:add']"
  68. >{{ $t('common.add') }}
  69. </el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. v-no-more-click
  74. type="danger"
  75. plain
  76. icon="el-icon-delete"
  77. size="mini"
  78. :disabled="multiple"
  79. @click="handleDelete"
  80. v-hasPermi="['iscs:propvalue:remove']"
  81. >{{ $t('common.batchDelete') }}
  82. </el-button>
  83. </el-col>
  84. <right-toolbar
  85. :showSearch.sync="showSearch"
  86. @queryTable="getList"
  87. ></right-toolbar>
  88. </el-row>
  89. <el-table
  90. v-loading="loading"
  91. :data="PropertyValueList"
  92. @selection-change="handleSelectionChange"
  93. >
  94. <el-table-column type="selection" width="55" align="center"/>
  95. <el-table-column :label="$t('mes.standardPropertyForm.recordId')" align="center" prop="recordId">
  96. </el-table-column>
  97. <el-table-column :label="$t('mes.standardPropertyForm.valueName')" align="center" prop="valueName"/>
  98. <el-table-column
  99. :label="$t('common.remark')"
  100. align="center"
  101. prop="remark"
  102. />
  103. <el-table-column
  104. :label="$t('common.createTime')"
  105. align="center"
  106. prop="createTime"
  107. />
  108. <el-table-column
  109. :label="$t('common.operation')"
  110. align="center"
  111. class-name="small-padding fixed-width"
  112. >
  113. <template slot-scope="scope">
  114. <el-button
  115. v-no-more-click
  116. size="mini"
  117. type="text"
  118. icon="el-icon-edit"
  119. @click="handleUpdate(scope.row)"
  120. v-hasPermi="['iscs:propvalue:edit']"
  121. >{{ $t('common.edit') }}
  122. </el-button>
  123. <el-button
  124. v-no-more-click
  125. size="mini"
  126. type="text"
  127. icon="el-icon-delete"
  128. @click="handleDelete(scope.row)"
  129. v-hasPermi="['iscs:propvalue:remove']"
  130. >{{ $t('common.delete') }}
  131. </el-button>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. <pagination
  136. v-show="total > 0"
  137. :total="total"
  138. :page.sync="queryParams.current"
  139. :limit.sync="queryParams.size"
  140. @pagination="getList"
  141. />
  142. <!-- 添加或修改物资对话框 -->
  143. <el-dialog :visible.sync="open" width="580px" append-to-body>
  144. <div slot="title" class="dialog-title">
  145. <i></i>
  146. <span class="title">{{ title }}</span>
  147. </div>
  148. <el-form ref="form" :model="form" :rules="rules" label-width="130px">
  149. <el-form-item :label="$t('mes.standardPropertyForm.propertyId')" prop="propertyId">
  150. <el-input
  151. disabled
  152. style="width: 350px"
  153. v-model="form.propertyId"
  154. :placeholder="$t('mes.standard.propertyNamePlaceholder')"
  155. />
  156. </el-form-item>
  157. <el-form-item :label="$t('mes.standardPropertyForm.valueName')" prop="valueName">
  158. <el-input
  159. style="width: 350px"
  160. v-model="form.valueName"
  161. :placeholder="$t('mes.standardPropertyForm.valueNamePlaceholder')"
  162. />
  163. </el-form-item>
  164. <el-form-item :label="$t('common.remark')" prop="remark">
  165. <el-input
  166. type="textarea"
  167. style="width: 350px"
  168. v-model="form.remark"
  169. :placeholder="$t('mes.standard.remarkPlaceholder')"
  170. />
  171. </el-form-item>
  172. </el-form>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button v-no-more-click type="primary" @click="submitForm"
  175. >{{ $t('common.confirm') }}
  176. </el-button
  177. >
  178. <el-button v-no-more-click @click="cancel">{{ $t('common.cancel') }}</el-button>
  179. </div>
  180. </el-dialog>
  181. </div>
  182. </template>
  183. <script>
  184. import {
  185. PropertyValuePage,
  186. addPropertyValue,
  187. updatePropertyValue,
  188. deletePropertyValue,
  189. selectPropertyValueById
  190. } from '@/api/mes/standard/propertyForm'
  191. import Treeselect from '@riophae/vue-treeselect'
  192. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  193. import Template from '@/views/print/printtemplate/list.vue'
  194. export default {
  195. name: 'Team',
  196. components: {
  197. Template,
  198. Treeselect
  199. },
  200. dicts: ['material_status', 'file_type'],
  201. data() {
  202. return {
  203. //自动生成编码
  204. autoGenFlag: false,
  205. optType: undefined,
  206. // 遮罩层
  207. loading: true,
  208. // 选中数组
  209. ids: [],
  210. codes: [],
  211. // 非单个禁用
  212. single: true,
  213. // 非多个禁用
  214. multiple: true,
  215. // 显示搜索条件
  216. showSearch: true,
  217. // 总条数
  218. total: 0,
  219. // 班组表格数据
  220. PropertyValueList: [],
  221. // 弹出层标题
  222. title: '',
  223. // 是否显示弹出层
  224. open: false,
  225. // 查询参数
  226. createTime: '',
  227. queryParams: {
  228. current: 1,
  229. size: 10,
  230. propertyName: '',
  231. valueName: '',
  232. propertyId: null
  233. },
  234. // 表单参数
  235. form: {
  236. propertyId: ''
  237. },
  238. }
  239. },
  240. computed: {
  241. rules() {
  242. return {
  243. valueName: [
  244. { required: true, message: this.$t('mes.standardPropertyForm.valueNameRequired'), trigger: 'blur' }
  245. ],
  246. materialsTypeId: [
  247. { required: true, message: this.$t('mes.standard.materialsTypeRequired'), trigger: 'blur' }
  248. ]
  249. };
  250. }
  251. },
  252. created() {
  253. this.getList()
  254. },
  255. methods: {
  256. goBack() {
  257. this.$router.push('/material/standard')
  258. },
  259. /** 查询物资信息列表 */
  260. getList() {
  261. this.loading = true
  262. this.queryParams.propertyId = this.$route.query.propertyId
  263. this.queryParams.propertyName = this.$route.query.propertyName
  264. PropertyValuePage(this.queryParams).then((response) => {
  265. console.log(response, '获取物资说明 ')
  266. this.PropertyValueList = response.data.records
  267. this.total = response.data.total
  268. this.loading = false
  269. })
  270. },
  271. // 取消按钮
  272. cancel() {
  273. this.open = false
  274. this.reset()
  275. },
  276. // 表单重置
  277. reset() {
  278. this.form = {
  279. propertyName: ''
  280. }
  281. this.resetForm('form')
  282. this.autoGenFlag = false
  283. },
  284. /** 搜索按钮操作 */
  285. handleQuery() {
  286. this.getList()
  287. },
  288. /** 重置按钮操作 */
  289. resetQuery() {
  290. this.resetForm('queryForm')
  291. this.handleQuery()
  292. },
  293. // 多选框选中数据
  294. handleSelectionChange(selection) {
  295. this.ids = selection.map(item => item.recordId)
  296. this.single = selection.length !== 1
  297. this.multiple = !selection.length
  298. },
  299. /** 新增按钮操作 */
  300. handleAdd() {
  301. this.reset()
  302. this.open = true
  303. this.form.propertyId = this.$route.query.propertyId
  304. this.title = this.$t('mes.standardPropertyForm.addPropertyValue')
  305. this.optType = 'add'
  306. },
  307. /** 修改按钮操作 */
  308. handleUpdate(row) {
  309. this.reset()
  310. selectPropertyValueById(row.recordId).then((response) => {
  311. console.log(response, '修改')
  312. this.form = response.data
  313. this.open = true
  314. this.title = this.$t('mes.standardPropertyForm.editPropertyValue')
  315. this.optType = 'edit'
  316. })
  317. },
  318. /** 提交按钮 */
  319. submitForm() {
  320. this.$refs['form'].validate((valid) => {
  321. if (valid) {
  322. if (this.form.recordId != null) {
  323. updatePropertyValue(this.form).then((response) => {
  324. console.log(response, '修改返回')
  325. this.$modal.msgSuccess(this.$t('mes.standardPropertyForm.editSuccess'))
  326. this.open = false
  327. this.getList()
  328. })
  329. } else {
  330. console.log(this.form, '新增参数')
  331. addPropertyValue(this.form).then((response) => {
  332. console.log(response, '新增返回')
  333. this.$modal.msgSuccess(this.$t('mes.standardPropertyForm.addSuccess'))
  334. this.open = false
  335. this.getList()
  336. })
  337. }
  338. }
  339. })
  340. },
  341. /** 删除按钮操作 */
  342. handleDelete(row) {
  343. const recordId = row.recordId || this.ids
  344. this.$modal
  345. .confirm(this.$t('mes.standardPropertyForm.deleteConfirm'))
  346. .then(function() {
  347. return deletePropertyValue(recordId)
  348. })
  349. .then(() => {
  350. this.getList()
  351. this.$modal.msgSuccess(this.$t('mes.standardPropertyForm.deleteSuccess'))
  352. })
  353. .catch(() => {
  354. })
  355. }
  356. }
  357. }
  358. </script>
  359. <style lang="scss" src="@/assets/styles/dialog-title.scss" scoped>
  360. .el-input-width {
  361. width: 380px !important;
  362. }
  363. </style>