Edit.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <el-dialog
  3. :close-on-click-modal="false"
  4. :close-on-press-escape="false"
  5. :title="title"
  6. :append-to-body="true"
  7. :visible.sync="isVisible"
  8. width="900px"
  9. top="50px"
  10. >
  11. <el-form ref="form" :model="tenant" :rules="rules" label-position="right" label-width="130px">
  12. <!-- 列表数据 -->
  13. <el-table
  14. :key="tableKey"
  15. ref="table"
  16. v-loading="loading"
  17. :data="tableData.data"
  18. border
  19. fit
  20. row-key="id"
  21. style="width: 100%;"
  22. @selection-change="onSelectChange"
  23. @cell-click="cellClick"
  24. >
  25. <!-- 序号 -->
  26. <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
  27. <template slot-scope="scope">
  28. <div>
  29. {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
  30. </div>
  31. </template>
  32. </el-table-column>
  33. <!--<el-table-column align="center" type="selection" width="50" :reserve-selection="true" />-->
  34. <el-table-column prop="cuttingToolName" label='刀具名称' :show-overflow-tooltip="true"></el-table-column>
  35. <el-table-column prop="specifications" label='刀具规格' width="180px"></el-table-column>
  36. <el-table-column prop="cutterCode" label='刀具编码' width="180px"></el-table-column>
  37. <el-table-column prop="remark" label='备注' width="180px"></el-table-column>
  38. <!-- <el-table-column prop="lockStatus" label='是否锁定'>
  39. <template slot-scope="{ row }">
  40. <el-tag :type="row.lockStatus=='1' ? 'success' : 'danger'">
  41. {{ row.lockStatus=='1' ? $t("common.no") : $t("common.yes") }}
  42. </el-tag>
  43. </template>
  44. </el-table-column>
  45. &lt;!&ndash; 启用状态 &ndash;&gt;
  46. <el-table-column prop="programId" label='启用状态'>
  47. <template slot-scope="{ row }">
  48. <el-tag :type="row.programId==null ? 'success' : 'danger'">
  49. {{ row.programId==null ? '可用' : '占用' }}
  50. </el-tag>
  51. </template>
  52. </el-table-column>-->
  53. </el-table>
  54. </el-form>
  55. <div slot="footer" class="dialog-footer">
  56. <el-button plain type="warning" @click="isVisible = false">{{ $t('common.cancel') }}</el-button>
  57. </div>
  58. </el-dialog>
  59. </template>
  60. <script>
  61. import { initQueryParams } from '@/utils/commons'
  62. // import Pagination from "@/components/Pagination"
  63. // 【仓库类型管理】-API
  64. import warehouseTypeMgrApi from "@/api/modelingCenter/warehouseTypeMgr"
  65. import customizeCuttingToolApi from "@/api/prepareProductMgr/customizeCuttingTool"
  66. // 【边线库管理】-API
  67. import lineSideMgrApi from "@/api/lineSideLibrary/lineSideMgr"
  68. export default {
  69. name: 'TenantEdit',
  70. components: {
  71. // Pagination
  72. },
  73. props: {
  74. dialogVisible: {
  75. type: Boolean,
  76. default: false
  77. },
  78. title: {
  79. type: String,
  80. default: ''
  81. }
  82. },
  83. data () {
  84. return {
  85. type: 'add',
  86. dialog: {
  87. isVisible: false,
  88. title: ""
  89. },
  90. tableKey: 0,
  91. queryParams: initQueryParams({}),
  92. selection: [],
  93. loading: false,
  94. tableData: {
  95. total: 0
  96. },
  97. tenant: this.initTenant(),
  98. screenWidth: 0,
  99. width: this.initWidth(),
  100. confirmDisabled: false,
  101. dicts:{
  102. NATION: {}
  103. },
  104. roles: [],
  105. rules: {
  106. name: [
  107. { required: true, message: this.$t("rules.require"), trigger: 'blur' }
  108. ]
  109. }
  110. }
  111. },
  112. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  113. created() {
  114. // 加载列表数据
  115. // this.fetch()
  116. },
  117. computed: {
  118. isVisible: {
  119. get () {
  120. return this.dialogVisible
  121. },
  122. set () {
  123. this.close()
  124. this.reset()
  125. }
  126. }
  127. },
  128. mounted () {
  129. window.onresize = () => {
  130. return (() => {
  131. this.width = this.initWidth()
  132. })()
  133. }
  134. },
  135. methods: {
  136. initTenant () {
  137. return {
  138. id: '',
  139. name: '',
  140. status: '1',
  141. cutterCode:''
  142. }
  143. },
  144. initWidth () {
  145. this.screenWidth = document.body.clientWidth
  146. if (this.screenWidth < 991) {
  147. return '90%'
  148. } else if (this.screenWidth < 1400) {
  149. return '45%'
  150. } else {
  151. return '800px'
  152. }
  153. },
  154. setTenant (val, dicts) {
  155. if(val){
  156. console.log("库位产品:", val);
  157. this.tenant = { ...val }
  158. // 加载列表数据
  159. this.getList(val);
  160. }
  161. // 字典表
  162. this.dicts = dicts
  163. },
  164. close () {
  165. this.$emit('close')
  166. },
  167. onSelectChange (selection) {
  168. this.selection = selection
  169. },
  170. reset () {
  171. // 先清除校验,再清除表单,不然有奇怪的bug
  172. this.$refs.form.clearValidate()
  173. this.$refs.form.resetFields()
  174. this.tenant = this.initTenant()
  175. },
  176. submitForm () {
  177. this.$refs.form.validate((valid) => {
  178. if (valid) {
  179. this.confirmDisabled = true
  180. if (this.type === 'add') {
  181. this.save()
  182. } else {
  183. this.update()
  184. }
  185. } else {
  186. return false
  187. }
  188. })
  189. },
  190. save () {
  191. warehouseTypeMgrApi.save(this.tenant)
  192. .then((response) => {
  193. const res = response.data
  194. if (res.isSuccess) {
  195. this.isVisible = false
  196. this.$message({
  197. message: this.$t('tips.createSuccess'),
  198. type: 'success'
  199. })
  200. // 通知列表
  201. this.$emit("success");
  202. // 通知列表-并关闭弹出框
  203. this.$emit("close");
  204. }
  205. }).finally(() => {
  206. this.confirmDisabled = false
  207. return true
  208. })
  209. },
  210. update () {
  211. warehouseTypeMgrApi.update(this.tenant)
  212. .then((response) => {
  213. const res = response.data
  214. if (res.isSuccess) {
  215. this.isVisible = false
  216. this.$message({
  217. message: this.$t('tips.updateSuccess'),
  218. type: 'success'
  219. })
  220. // 通知列表
  221. this.$emit("success");
  222. // 通知列表-并关闭弹出框
  223. this.$emit("close");
  224. }
  225. }).finally(() => {
  226. this.confirmDisabled = false
  227. return true
  228. })
  229. },
  230. // 获取列表数据
  231. getList (row) {
  232. this.loading = true
  233. lineSideMgrApi.getCuttingToolByCutterCode({ "id": row.toolId }).then(response => {
  234. const res = response.data;
  235. console.log("res123123214==== ", res);
  236. if (res.isSuccess) {
  237. this.tableData = res
  238. }
  239. // eslint-disable-next-line no-return-assign
  240. }).finally(() => this.loading = false)
  241. },
  242. fetch (params = {}) {
  243. this.loading = true
  244. if (this.queryParams.timeRange) {
  245. this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
  246. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
  247. }
  248. this.queryParams.current = params.current ? params.current : this.queryParams.current
  249. this.queryParams.size = params.size ? params.size : this.queryParams.size
  250. lineSideMgrApi.page(this.queryParams).then(response => {
  251. const res = response.data
  252. if (res.isSuccess) {
  253. this.tableData = res.data
  254. }
  255. // eslint-disable-next-line no-return-assign
  256. }).finally(() => this.loading = false)
  257. },
  258. cellClick (row, column) {
  259. if (column['columnKey'] === "operation") {
  260. return
  261. }
  262. let flag = false
  263. this.selection.forEach((item) => {
  264. if (item.id === row.id) {
  265. flag = true
  266. this.$refs.table.toggleRowSelection(row)
  267. }
  268. })
  269. if (!flag) {
  270. this.$refs.table.toggleRowSelection(row, true)
  271. }
  272. }
  273. }
  274. }
  275. </script>
  276. <style lang="scss" >
  277. .avatar-uploader .el-upload {
  278. border: 1px dashed #d9d9d9;
  279. border-radius: 6px;
  280. cursor: pointer;
  281. position: relative;
  282. overflow: hidden;
  283. }
  284. .avatar-uploader .el-upload:hover {
  285. border-color: #409eff;
  286. }
  287. .avatar-uploader-icon {
  288. font-size: 28px;
  289. color: #8c939d;
  290. width: 100px;
  291. height: 100px;
  292. line-height: 100px;
  293. text-align: center;
  294. }
  295. .avatar {
  296. width: 100px;
  297. height: 100px;
  298. display: block;
  299. }
  300. .checkUsed{
  301. display: inline-block;
  302. margin-left: 10px;
  303. color: #1890ff;
  304. }
  305. </style>